Search code examples
.netpdfgdiprinting

Generating PDF files from .NET by using standard .NET GDI printing classes


I'm looking for a way to generate PDF files using the standard PrintDocument and Graphics (GDI) classes in .NET. As far as I know, the only way to do that is by printing to a PDF printer.

The problem is that a PDF printer driver always asks for a filename, but I need to control the filename from my code. Using a PDF library like PDFSharp or DynamicPDF is not an option, because they all provide their own API for generating PDF files.

I need this for an internal application, so dependencies are not a problem.

My question is simple: is there a way to control a printer driver (Adobe Acrobat, PDFCreator, ...) in such a way that a filename can be specified and the user is not prompted for anything?


Solution

  • Did some more research, and although I still didn't find a perfect solution, there are a few products that install a PDF printer driver and which allow you in some way to control the name of the file to be generated:

    Bullzip and PDFCreator are free.

    UPDATE: Found another one that looks very promising: