0

hi i have a win form app in c# that in this form i have 3 image and a label. i want to prite these objects into a pdf file. please help me

David Conde
  • 4,631
  • 2
  • 35
  • 48
hamed
  • 163
  • 1
  • 3
  • 13

1 Answers1

1

This is how I would do this:

  1. Generate a bitmap from the WinForm control (using Control.DrawToBitmap). You can wrap your images/buttons into the Panel control and generate the bitmap from that panel.
  2. Use any PDF library to generate PDF document based on the bitmap.

For example, that't how to create PDF document from the bitmap using ABCpdf:

WebSupergoo.ABCpdf7.Doc doc = new WebSupergoo.ABCpdf7.Doc();

doc.SetInfo(0, "License", "[your license code || trial license"]);    
doc.Page = doc.AddPage();

doc.AddImageBitmap(myPanel.DrawToBitmap(), false);

doc.PageNumber = 1;
doc.Flatten();

doc.Save("myfile.pdf");

-- Pavel

volpav
  • 5,090
  • 19
  • 27
  • Also possible you could skip the panel.DrawToBitmap() and add the images directly in to the document. (What I was about to write using TallPDF but not distinctly different enough to warrant a new answer) – hometoast Jan 06 '11 at 11:39
  • @hometoast: Sure, you can do that. The panel could be used if you want to preserve the layout of child control. – volpav Jan 06 '11 at 11:42