I have a C# .net
program that creates various documents. These documents should be stored in different locations and with different, clearly defined names.
To do so, I use the System.Drawing.Printing.PrintDocument
class.
I select the Microsoft Print to PDF
as printer with this statement:
PrintDocument.PrinterSettings.PrinterName = "Microsoft Print to PDF"
;
While doing so I'm able to print my document in a pdf file
. The user gets a file select dialog. He can then specify in this dialog box the name of the pdf file and where to store it.
As the amount of files are large and it is annoying and error-prone to find always the correct path and name, I would like to set the correct path and filename in this dialog box programmatically.
I have already tested these attributes:
PrintDocument.PrinterSettings.PrintFileName
PrintDocument.DocumentName
Writing the required path and filename to these attributes didn't help.
Does anybody know, how to set the default values for path and filename for the Microsoft Print to PDF
printer in C#?
Note: My environment : Windows 10, Visual Studio 2010, .net framework 4.5