Win2PDF uses standard Windows APIs for settings when possible. This includes settings for paper size, paper orientation, and resolution.
You can set the PDF file name from VB.NET or C# using the .NET framework Printersettings.PrintFileName property. You should also set the PrinterSettings.PrintToFile property to true:
PrintDocument.PrinterSettings.PrintFileName = "C:\Users\test\AppData\Local\Temp\aFile.pdf"
PrintDocument.PrinterSettings.PrintToFile = true;
For settings that aren't available through the Windows API, Win2PDF can use the Windows registry. This makes it easy to control Win2PDF from almost any development environment.
Win2PDF looks for registry values at the following locations and in the following order:
"HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Dane Prairie Systems\Win2PDF"
"HKEY_CURRENT_USER\Software\Dane Prairie Systems\Win2PDF" and
"HKEY_LOCAL_MACHINE\Software\Dane Prairie Systems\Win2PDF"
The first registry location is used for the Visual Basic and VB.NET "SaveSetting" function. From Visual Basic or VB.NET, you can call SaveSetting with the following parameters to control Win2PDF:
SaveSetting "Dane Prairie Systems", "Win2PDF", ValueName, Value
From C#, you can use the same fully qualified SaveSetting function name:
Microsoft.VisualBasic.Interaction.SaveSetting("Dane Prairie Systems", "Win2PDF", ValueName, Value)
Where "ValueName" and "Value" will depend on the Win2PDF setting to control. The SaveSetting command only works with Win2PDF registry settings that use a string type.
The HKEY_CURRENT_USER registry location is useful if you want the setting to apply only to the current user. This is especially important when using Win2PDF in a multi-user environment such as Windows Terminal Services.
The HKEY_LOCAL_MACHINE location is useful if you want the setting to apply to all users, the application is running as part of a Windows service, or if your application is only going to be used with a single user.
After the document is created, the registry value will be deleted by Win2PDF. If you would like the setting to apply to all documents without having to add the registry value for each document, you can create a non-zero registry value named "persistent" to one of the locations listed above. This will prevent Win2PDF from deleting the value after each document. Most settings also have a "Default" setting that is not deleted after each document.
The following Win2PDF settings can be controlled from the registry. All settings with the "String" type support Environment Variable Expansion if saved as REG_EXPAND_SZ.
Value Name |
Type |
Description |
String |
Controls the output file name Is automatically deleted after each document. |
|
String |
Controls the output file name. Is not automatically deleted after each document. |
|
String |
Same as PDFFileName, but is deleted after the document has been created |
|
Dword |
Prevents registry values from being deleted when it is set to a non-zero value |
|
String |
Sets the document title, or file name displayed in the Win2PDF file save window. Is automatically deleted after each document. |
|
String |
Sets the default document title, or file name displayed in the Win2PDF file save window. Is not automatically deleted after each document. |
|
String |
Sets the document author |
|
String |
Sets the document subject |
|
String |
Sets the document keywords |
|
Dword |
Enables encryption, e-mail, view, and print PDF options |
|
Dword |
Disables options from the file save window |
|
String |
Automatically executes the application specified after PDF creation and waits for the application to close. Deleted after each document. |
|
String |
Automatically executes the application specified after PDF creation and immediately returns control to the printing application. Deleted after each document. |
|
String |
Automatically executes the application specified after PDF creation and waits for the application to close. Not deleted after each document. |
|
String |
Automatically executes the application specified after PDF creation and immediately returns control to the printing application. Not deleted after each document. |
|
String |
Sets the user password (Win2PDF Pro) |
|
String |
Sets the master password (Win2PDF Pro) |
|
String |
Sets the email "To:"recipient addresses when the "Send PDF" option is enabled. Deleted after each document. |
|
String |
Sets the email "To:"recipient addresses when the "Send PDF" option is enabled. Not deleted after each document. |
|
String |
Sets the email "CC:" recipient addresses when the "Send PDF" option is enabled. Deleted after each document. |
|
String |
Sets the email "CC:" recipient addresses when the "Send PDF" option is enabled. Not deleted after each document. |
|
String |
Sets the email "BCC:" recipient addresses when the "Send PDF" option is enabled. Deleted after each document. |
|
String |
Sets the email "BCC:" recipient addresses when the "Send PDF" option is enabled. Not deleted after each document. |
|
String |
Sets the email subject when the "Send PDF" option is enabled. Deleted after each document. |
|
String |
Sets the email subject when the "Send PDF" option is enabled. Not deleted after each document. |
|
String |
Sets the email body text when the "Send PDF" option is enabled. Deleted after each document. |
|
String |
Sets the email body text when the "Send PDF" option is enabled. Not deleted after each document. |
|
String |
Sets the email body HTML text when the "Send PDF" option is enabled. Deleted after each document. |
|
String |
Sets the email body HTML text when the "Send PDF" option is enabled. Not deleted after each document. |
|
String |
Verifies email addresses using the default address book |
|
String |
Sets the watermark PDF file |
|
String |
Sets the default watermark PDF file |
|
Dword |
Excludes the watermark from being applied to the first number of pages of a document. |
|
Dword |
Excludes the watermark from being applied to the last number of pages of a document. |
|
Dword |
Include the watermark to the specified number of pages from the beginning of the document. |
|
Dword |
Include the watermark to the specified number of pages from the end of the document. |
|
Dword |
Always excludes the watermark from being applied to the first number of pages of a document. |
|
Dword |
Always excludes the watermark from being applied to the last number of pages of a document. |
|
Dword |
Always include the watermark to the specified number of pages from the beginning of the document. |
|
Dword |
Always include the watermark to the specified number of pages from the end of the document. |
|
String |
Sets a specific printer instead of the Windows default printer with "print file" file_options are set. |
|
String |
Sets a default specific printer instead of the Windows default printer with "print file" file_options are set. |
|
PDFDocumentScaling |
Dword |
Sets a document scaling percent (1-999). 100 indicates no scaling. |
auto merge interval |
Dword |
Time in milliseconds between documents for auto-merge feature. Set to 0 to disable auto-merge. |
disable autoname keyboard check |
Dword |
Disables the shift key checking when the auto-name feature is enabled. |
Dword |
Controls which save formats are displayed in the Win2PDF file save window. |
|
JPEG2000 Ratio |
Dword |
Sets a compression ratio for JPEG 2000 compression (1-99). Requires "Enable JPEG2000" file option. |
String |
Adds an option to the Win2PDF file save window to selectively execute "Post Action" or "Default Post Action". |
|
String |
Append the PDF file specified to the newly created PDF once. |
|
String |
Prepend the PDF file specified to the newly created PDF once. |
|
String |
Always append the PDF file specified to the newly created PDF. |
|
String |
Always prepend the PDF file specified to the newly created PDF. |
|
PDFAppendToExistingFile |
Dword |
When set to 1, automatically appends to the file specified by PDFFileName, PDFPostFileName, or PDFDefaultFileName |
PDFPrependToExistingFile |
Dword |
When set to 1, automatically prepends to the file specified by PDFFileName, PDFPostFileName, or PDFDefaultFileName |
shell print |
Dword |
When set to 1, use the Windows default PDF viewer to print PDF files when the "Print File" option is enabled. |
PDFPreview |
Dword |
When set to 1, use the Win2PDF Desktop PDF viewer instead of the default Windows PDF viewer. |
PDFAutoNameContentSearchWord PDFAutoNameContentSearchWord2 PDFAutoNameContentSearchWord3 |
String |
Win2PDF searches the text of the current PDF for the word specified. If the word is found, the auto-name variable %PDFAutoNameContentSearch% is filled with the word after the search word. |
Dword |
Specified the length of the text field to use for the auto-name variable %PDFAutoNameContentPosition% |
If you create the any of the string registry values as a REG_EXPAND_SZ instead of a REG_SZ type, the value will be expanded from environment variables. The environment variables are specified with "%" characters at the beginning and end of the variables as in "%HOMEPATH%". A list of Win2PDF environment variables that can be used in registry settings is at PDF Auto-name: User Defined. The REG_EXPAND_SZ option is not available from the Visual Basic SaveSetting command. The %DATE% and %TIME% environment variables are not expanded by this option.
The registry methods are not safe when used with programs that have multiple threads or multiple processes that access Win2PDF unless you use a REG_EXPAND_SZ setting for "PDFDefaultFileName" with a %PDFMillisecond% or %PDFIncrement% variable to prevent files from being overwritten. For these types of programs, you need to ensure that only one thread or process has access to Win2PDF at a time by using a Windows critical section or mutex. The Windows printer interfaces do not have these limitations.
When multiple instances of Win2PDF are installed, Win2PDF first looks in the registry locations based on the instance name of Win2PDF. This allows separate settings for different instance of Win2PDF. For example, if the current instance of Win2PDF is named "Win2PDF (Copy 1)" the following registry locations would be checked before the standard registry locations:
"HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Dane Prairie Systems\Win2PDF (Copy 1)"
"HKEY_CURRENT_USER\Software\Dane Prairie Systems\Win2PDF (Copy 1)" and
"HKEY_LOCAL_MACHINE\Software\Dane Prairie Systems\Win2PDF (Copy 1)"
If a setting doesn't exist under the instance name section of the registry, then Win2PDF checks the standard locations.