Hey guys,
I am having a problem where i want to print a image and a simple string.
i would want that when i print i get this on paper : Click Here For Image

I looked up printDocument, printDialog and printPreviewControl from MSDN and got a few examples but i did not really understand them, i looked up this topic on Google but its very little discussed.

I don't know the procedure on how to print to paper so if someone can explain to me how its done it would be very appreciated or if you can make an example code snippet i would be very thankful.

Thank you in advanced

Here's a simple class that will print an image and a string to a page using the default printer. This may not do everything you want but it should be enough to show you what is required. You can use things like the image size to figure out what location to start the printing at, and where to set the printing location for the text.

    public class PrintImg_Txt
    {
        private PrintDocument pd1 = new PrintDocument();
        private Image _PrintImage;
        private string _PrintString = "";
        private Font _pdfont = new Font("Microsoft Sans Serif", 8.25f);
        private string _Name = "";
        private bool _Landscape = false;
        public PrintImg_Txt(Image PrintImage, string PrintString = "", bool Landscape = false)
        {
            _PrintImage = PrintImage;
            _PrintString = PrintString;
            _Landscape = Landscape;
        }

        public void Print()
        {
            pd1.DefaultPageSettings.Landscape = _Landscape;
            pd1.PrintPage += new PrintPageEventHandler(pd1_PrintPage);
            if (_Name != "")
                _PrintString = _Name + "\n\n" + _PrintString;
            pd1.Print();
        }
        private void pd1_PrintPage(object sender, PrintPageEventArgs e)
        {

            Point loc = new Point(100, 100);
            e.Graphics.DrawImage(_PrintImage, loc);
            // Draws the string within the bounds of the page
            e.Graphics.DrawString(_PrintString, _pdfont, Brushes.Black,
                e.MarginBounds, StringFormat.GenericTypographic);
        }
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.