Click here to Skip to main content
15,906,341 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi All,
How to print a image of an picturebox in runtime?

I want to print barcode of a product purchase, barcode is in a image format an generate in picturebox.

How to print multiple barcode of products purchase,it should print product barcode in no. of quantity of product and after that next product barcode which is in the list.


please help me in this reagard.

Thanks in Advance.
Posted
Updated 23-May-11 19:55pm
v2

try this code for to print an image of a picturebox

private void button1_Click(object sender, EventArgs e)
        {
            PrintDocument doc = new PrintDocument();
            doc.PrintPage += this.Doc_PrintPage;
            PrintDialog dlgSettings = new PrintDialog();
            dlgSettings.Document = doc;
            if (dlgSettings.ShowDialog() == DialogResult.OK)
            {
                doc.Print();
            }
        }
 
private void Doc_PrintPage(object sender, PrintPageEventArgs e)
        {
             float x = e.MarginBounds.Left;
              float y = e.MarginBounds.Top;
            Bitmap bmp = new Bitmap(this.pictureBox1.Width, this.pictureBox1.Height);
            this.pictureBox1.DrawToBitmap(bmp, new Rectangle(0, 0, this.pictureBox1.Width, this.pictureBox1.Height));
            e.Graphics.DrawImage((Image)bmp, x, y);
        }
 
Share this answer
 
v2
Comments
acsie 11-Jan-13 13:01pm    
Display and Print Multiple Images, use for or loop, using vb.net PrintDocument1 and PrintPreviewDialog1, each page displayed three columns and eight rows 24images without limitation of images
It does not matter what kind of graphics do you print. You need to use the class System.Drawing.Printing.PrintDocument. The idea of using it is: you obtain an instance of the class System.Drawing.Graphics and render all the graphical primitive you need.

See the code sample here:
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument(v=VS.100).aspx[^], it explains everything.

Also, look at this article:
Simplified .NET Printing in C#[^].

—SA
 
Share this answer
 
You should study theseBarcode .NET Control[^]link


Best Regard ,
Theingi Win
 
Share this answer
 
thanx you all .
But i also want to print multiple barcode images in a single page. Side by side.
Please help me in this regard also.
 
Share this answer
 

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