hi i have a win form app in c# that in this for开发者_JAVA百科m i have 3 image and a label. i want to prite these objects into a pdf file. please help me
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
精彩评论