Automating Print To PDF From PrintDocument In .NET

2.6k views Asked by At

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.

2

There are 2 answers

7
Graffito On BEST ANSWER

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).

0
Binod Mahto On

I had similar issues to print pdf automatically through c# web application hosted in IIS. I too have provided the solution in stackoverflow you can refer that. I'm it will help you.

How to print to network printer through application hosted in IIS

Note: In case of Web Application or Window Service, You must have to do the impersonation if the app doesn't runs under a user who has the privilege to access the printer.