.Net export Windows form to PDF

2.4k Views Asked by At

Is there a way to export Windows forms directly to a PDF in C#? I created some nice plots using ZedGraph, added them to a Windows form and would like to export them to a PDF. PrintForm looks promising if there is some way to select the destination as a PDF.

Thanks.

1

There are 1 best solutions below

0
On BEST ANSWER

You could set up a PDF printer like BullZip, and use PrintForm to print to it. If you want it fully programmatic and encapsulated within your program (no "environmental" dependencies like an installed printer), I'd recommend iTextSharp, which is a .NET managed library providing PDF composition features. You'd use it in this case by capturing an image of your form using the CopyFromScreen method of a Bitmap, creating a new PDF document and pasting in the image with iTextSharp. Here's some reading on the subject: http://www.mikesdotnetting.com/Article/87/iTextSharp-Working-with-images