I have a C# .net program that creates various documents. These documents must be stored in different places and with different clearly defined names.
For this, I use the System.Drawing.Printing.PrintDocument class. I choose Microsoft Print to PDF as a printer with this statement:
PrintDocument.PrinterSettings.PrinterName = "Microsoft Print to PDF" ;
With this, I can print my document in pdf file . The user receives a file selection dialog. Then he can specify in this dialog box the name of the pdf file and where to store it.
Since the number of files is large and it is annoying and error prone to always find the correct path and name, I would like to set the correct path and file name in this dialog box programmatically.
I have already tested these attributes:
PrintDocument.PrinterSettings.PrintFileName PrintDocument.DocumentName
Writing the required path and file name to these attributes did not help. Does anyone know how to set default values โโfor path and file name for Microsoft Print to PDF printer in C #?
Note. My environment : Windows 10, Visual Studio 2010, .net framework 4.5
source share