Search code examples
c#vb.netpdfprintdocument

Automating Print To PDF From PrintDocument In .NET


I'd like to export a VB .NET PrintDocument to a PDF automatically (i.e. without the need for any user interaction). I've been trying to find a free PDF SDK (or something similar) that will allow me to do this. I've tried a couple of free PDF printers (Bullzip and CutePDF), both of which bring up a save dialog when the document is printed. I'd like to be able to specify the name of the PDF and save location via code, but I don't think that can be done with either of those printers.

It would be good to hear what people facing the same issue have done in the past, paid-for options included. Thanks.


Solution

  • You can install BullZip and use the configuration tool to suppress all dialogs and generate the Pdf to a predefined file (same path for all print requests).

    In your code, before printing, update the PDF printer configuration file by changing the output filename in the BullZip settings. Update the PDF printer configuration file C:\Users\user_name\AppData\Roaming\PDF Writer\Bullzip PDF Printer\settings.ini (one may expect variations on the directory path).