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
Asked
Active
Viewed 2,484 times
0
-
1So what have you done so far? – leppie Jan 06 '11 at 06:33
-
'prite'(think you mean 'print') as in storing the images in the pdf. Or do you want the images been print out (out of the printer) – RvdK Jan 06 '11 at 07:25
-
yes i want print 3 images on a Form – hamed Jan 06 '11 at 08:53
1 Answers
1
This is how I would do this:
- 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.
- 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