Configuration Files / PDF Printer
The program is controlled by a wide variety of settings. Each of these settings can influence the output or the user experience. When the program runs it looks for the settings in a set of setting files. These files and their location are described in more detail below.
Configuration files are basically text files similar to INI files in structure. They can be modified using the Options dialog or the Printer API. You can also open and edit the files using Notepad or any other suitable editor. The files can be saved using Unicode, UFT-8 or just plain ANSI Encoding.
Runonce Settings
When a print job is sent to the program it will look for a runonce file. The runonce setting file (runonce.ini) is used to control the PDF creation from another program. A runonce settings file is only valid for one print job and will be removed automatically when it is read. All other settings files are ignored if a runonce file exists.
Normal Settings
In case there is no runonce file, the program will look for a normal settings file. The normal settings file (settings.ini) is written by the options dialog, which can be launched from the Start menu.
The settings.ini and user.ini are created after opening the 7-PDF Printer Options dialog window and after saving the dialog settings for the first time. Immediately after an installation, the directory is still empty.
After saving, the options dialog then creates the INI files...
Global Settings
The settings read from the normal settings file can be overwritten by settings in a global settings file (global.ini). A global settings file can contain a list of forced settings that apply to all users on the system (Example: As shared PDF printer). If the same setting is specified in both the normal setting file and the global setting file then the resulting value is taken from the global setting file. The global settings does not have any effect when a runonce settings file is used.
Default Settings
Default settings are the values that are used in case no values were specified elsewhere.
User Settings
A user file (user.ini) is created to store information such as the last file and folder name used by the user.
Runonce - Settings - Programmatic or access-protected PDF generation in multi-user environments (Citrix environments, terminal server)
When a print job is directed to the program, the first thing to do is look for a runonce file. The runonce configuration files have the highest priority for 7-PDF Printer. The runonce configuration file is used to control the production of PDF files from another external program (own program that preconfigures the 7-PDF Printer via COM, VBScript Macros etc.). A runonce configuration file is only valid for one print job at a time and will then be automatically deleted from the PDF printer. All other configuration files are ignored if a runonce file exists.
Handling of simultaneously programmatically triggered PDF print jobs
Simultaneous triggered PDF print jobs of this type could potentially be a problem because a runonce.ini could be overwritten by a second, simultaneously programmatically triggered print job. To prevent this, a special runonce configuration file can be generated programmatically, from the additional specification of the document name. The presence of such a runonce_documentname.ini file is recognized by the 7-PDF Printer and used for the respective document to be converted to PDF before searching for a normal runonce.ini configuration file. It is thus possible to bind dynamic configurations of the printer to the PDF print job by specifying the document name, and also prevents configuration files from being overwritten by simultaneously triggered print jobs.
Now, how do you get the document name for a PDF print job to programmatically create it according to this scheme to form a special runonce_dokumentnamen.ini configuration file in source code? The easiest way to do this is to watch the spooler dialog of the 7-PDF Printer.
The following picture shows the spooler dialog of a PDF print job to 7-PDF Printer that was triggered from the Windows application Microsoft Word Viewer for a Word document with the file name infile.doc.
For this spool request, a matching runonce_documentname.ini configuration file would look exactly as shown in the following figure:
You can see that the spaces in the document name of the runonce_documentname.ini configuration file have been replaced by URL encoding compliant codes %20 = spaces.
In Delphi, this was realized in source code:
djobname:= 'Microsoft Word Viewer - ' + ExtractFileName(txtInFile.Text);
rp:=oPDF.getSettingsFilePath(true);
djobname := StringReplace(djobname, '#','%23',[rfIgnoreCase, rfReplaceAll]);
djobname := StringReplace(djobname, ' ','%20',[rfIgnoreCase, rfReplaceAll]);
oPDF.WriteSettingsFile(ExtractFilePath(rp)+'runonce_'+djobname+'.ini');
An existing # character in the document to be printed would be replaced by the URL encoding %23, a space matching %20 etc.
The path in which the runonce file to be created is to be determined in the source by the COM method getSettingsFilePath()
. The runonce_documentname.ini configuration file is stored via the COM method WriteSettingsFile()
in the last statement.
File Names and Location
The table below lists the configuration files and their location. In the table below you will find the following constants: CSIDL_LOCAL_APPDATA, CSIDL_APPDATA, and CSIDL_COMMON_APPDATA. They refer to special folders in the operating system. These locations vary with different versions of the Microsoft Windows. Their values also change for different language versions of the operating system.
Runonce Settings | runonce.ini | {CSIDL_LOCAL_APPDATA}\PDF Writer\printername\ |
Normal Settings | settings.ini | {CSIDL_APPDATA}\PDF Writer\printername\ |
Global Settings | global.ini | {CSIDL_COMMON_APPDATA}\PDF Writer\printername\ |
Default Settings | defaults.ini | {CSIDL_COMMON_APPDATA}\PDF Writer\printername\ |
User Settings | user.ini | {CSIDL_APPDATA}\PDF Writer\printername\ |
The printername part of the file names must be substituted with the name of the printer that you want to control with the settings in the file.
If you want to see the values of CSIDL_LOCAL_APPDATA, CSIDL_APPDATA, and CSIDL_COMMON_APPDATA on your system, then you can run the gui.exe from the installation path of 7-PDF printer with the info command line switch. That will bring up a message box where you can see the calculated location of each of the settings files.
Complete DOS-Command: gui.exe info printer="7-PDF Printer"
The path information of the configuration files under a German Windows 7 installation.
The path details of the configuration files under a German Windows XP installation.
Encoding
The configuration files support different types of encoding. Depending on the type of encoding you choose, you must prefix the file content with a signature that identifies the encoding. Only ANSI files do not require any encoding. However, ANSI files cannot contain any international characters. When you use the printer API the encoding will be done by the API itself.
Unicode files are prefixed with two bytes 0xFF and 0xFE. This signature is for Little Endian Unicode. The other type of Unicode is named Big Endian Unicode and is prefixed with 0xFE followed by 0xFF. Little endian is preferred over big endian.
UTF-8 encoded files must be prefixed with the byte sequence 0xEF, 0xBB, 0xBF.