1

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.

Lukas Bystricky
  • 1,222
  • 6
  • 16
  • 34
  • Of course...You would have to write the code to generate the PDF. – Security Hound Nov 26 '12 at 16:15
  • "PrintForm looks promising if there is some way to select the destination as a PDF". Google "print to pdf" to find lots of 3rd party tools for selecting PDF as a print destination. – mbeckish Nov 26 '12 at 16:16

1 Answers1

4

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

KeithS
  • 70,210
  • 21
  • 112
  • 164