Specifying an output file name
|Top Previous Next|
In addition to being able to control the output file using the Win32 API, you can control the output file name by creating a string value in the registry at any of the standard registry locations. The "PDFFileName" value should be set to the full path name of the document. If the "PDFFileName" entry does not exist in the registry, the user will be prompted to enter a file name.
From Visual Basic, you can set the output file name using the following code sample:
SaveSetting "Dane Prairie Systems", "Win2PDF", "PDFFileName", filename
Where the filename parameter is the full path name for the file. By default, the "PDFFileName" entry is removed from the registry after each document is created and you must add the "PDFFileName" each time you print. If you want to prevent the "PDFFileName" from being removed after each document, you can create a DWord value named "persistent" at one of the standard registry locations.
The format type is determined by the filename extension. The following extensions are supported:
•.PDF - Portable Document Format
•.PDFA -PDF for Archiving (PDF/A). File is renamed with a .PDF extension after creation.
•.XPS - XML Paper Specification
•.TIFF or .TIF - Tagged Image File Format
•.SVG - Scalable Vector Graphics
If a file already exists at the location specified by "PDFFileName", it will be overwritten. If you want to prevent files from being overwritten, you can add a single asterisk character "*" to the file name to specify a wildcard. If a wildcard character exists, it will be replaced by a sequential number so that documents are never overwritten.
If you want to create a unique document name, you can use a single "%" character in the file name. The "%" character will be expanded to include a sequence of numbers based on the current date and time.
If you create the "PDFFileName" registry value as a REG_EXPAND_SZ instead of a REG_SZ type, the file name will be expanded from environment variables. The environment variables are specified with "%" characters at the beginning and end of the variables as in "%HOMEPATH%". If the environment variable does not exist, the first "%" character will be expanded by a sequences of numbers based on the date and time as described previously. 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.
Win2PDF sets the current PDF document title in an environment variable named "PDFTitle". You can use this in combination with a REG_EXPAND_SZ environment variable to set the file name to the document title. For example, if a "PDFFileName" entry with a REG_EXPAND_SZ type is set to "c:\%PDFTitle%*.pdf", Win2PDF will create a document using the document specified title without displaying a file save dialog and it will never overwrite an existing file.
If the application needs to determine when Win2PDF has finished creating the document, it can use "PDFPostFileName" instead of "PDFFileName". The behavior of "PDFPostFileName" is identical to "PDFFileName" except the registry value is not deleted by Win2PDF until the document has been created. The application can monitor the existence of this registry value to determine if Win2PDF is still processing the document.