Click here to Skip to main content
15,173,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am making a Windows Form Application to print barcodes on books. I have generated the barcode and displayed it in a Picture Box but I do not have any idea of how to print this Image. I have the barcode in an Image Object.

Please help me. The requirement is that I want to print this image at a specific position on a document because on various books the location of barcode can vary.

Thanks...
Posted

You can use the class System.Drawing.Printing.PrintDocument and print the Image of your instance of the PictureBox directly. The idea of this class is to get the instance of System.Drawing.Graphics from the event arguments of the class PrintPageEventArgs. You can use the method System.Drawing.Graphics.DrawImage.

Please see the code sample here:
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx[^].

See also:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.aspx[^].

—SA
   
Here is an article on CodeProject that should walk you through what you want. Ref: Print a WinForms User Control[^]
   
Comments
Rahul_Patel 11-Mar-12 5:55am
   
thnks sir.....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900