Click here to Skip to main content
15,893,904 members
Please Sign up or sign in to vote.
3.29/5 (4 votes)
See more:
Hello ;

I am extracting the images from database and store them in <list> images;
and then I want to print all the images in that list view each picture in saperated paper...

I tried to loop in the imagelist then to use e.graphic.drawimage...
but it show emptye print dialog box pront preview ....

any code for printing all the images in imagelist???
reagrds...
Posted

1 solution

Hi,
you can create a PrintDocument, then call the Print method. It does not show a Print Dialog, since you can manually set the options.

http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx[^]

Regards
Robert
 
Share this answer
 
Comments
Tamer Hatoum 14-Nov-10 4:22am    
thanks for your reply.. acctually I can print a picture from the imagelist , but it prints only the last image in the list, it doesnot create new page and print all the images .. this is my code :
private void button1_Click(object sender, System.EventArgs e)
{
PrintDocument doc = new PrintDocument();
doc.PrintPage += this.Doc_PrintPage;
printPreviewDialog1.Document = doc;
printPreviewDialog1.ShowDialog();
PrintDialog dlgSettings = new PrintDialog();
dlgSettings.Document = doc;

if (dlgSettings.ShowDialog() == DialogResult.OK)
{
doc.Print();
}

}
private void Doc_PrintPage(object sender, PrintPageEventArgs e)
{
Font font = new Font("Arial", 30);

float x = e.MarginBounds.Left;
float y = e.MarginBounds.Top;

float lineHeight = font.GetHeight(e.Graphics);

//for (int i = 0; i < 5; i++)
//{
// e.Graphics.DrawString("This is line " + i.ToString(), font, Brushes.Black, x, y);
// y += lineHeight;
// }
y += lineHeight;

// Image myimage = realimage[0];

e.Graphics.DrawImage(realimage[0], x, y);
e.Graphics.DrawImage(realimage[1], x, y);

}
plz help..
El_Codero 5-Mar-12 18:20pm    
Thanks for sharing this link!

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