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
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:
The System.Drawing code for a PrintDocument can be reused to generate a PDF with ABCpdf.NET from webSupergoo. See the System.Drawing example for more details. The component doesn't use a printer driver - it creates PDF directly - so doesn't require a filename to be specified.
Not sure if this is a solution you'd consider, but I've used iTextSharp to fill in PDF Forms and save them with a filename that's generated in code, not by the user. It also can generate complete PDFs from scratch, but I haven't delved that far into it.
Unless the printer drivers that you are using support this manually (of which none exist that I know of), you would have to write your own printer driver which you would be able to pass information to (such as the filename) during the print operation.
The drawbacks to this are the fact you would have to implement a printer driver, as well as the fact that it would have to be unmanaged code (you can't write drivers in .NET).
A product called Amyuni does this (I use it in a project) but I don't like the licencing, you may get on fine with it.
See Amyuni.com
Ryan
Dane-Prairie Systems http://www.win2pdf.com/ seems to capture the "print to file" string from the GDI calls and will create your PDF whereever you spec. Here's a quote from the manual:
Set the lpszOutput field of the DOCINFO structure to the fully qualified path name of the file, and then pass the DOCINFO structure to the Win32 StartDoc function.
Peter