data-id=windows-messaging
Windows Messaging
Distiller supports Windows messages that can perform the following tasks:
- Specify the file or files to process and the output destination
- Confirm when each file specified in the first Windows message has completed processing
- Determine the Distiller version number
The enumerated data types and constants necessary to use Windows messaging are defined in the file distctrl.h. This file is included in the Adobe Acrobat SDK. Source files that use the Distiller control interface must include distctrl.h.
Note
The
WM_COPYDATAinterface provides compatibility for older applications only. You cannot use any of Distiller’s newer features with it, such as Adobe PDF settings files and input piping.
data-id=specifying-input-and-output-files
Specifying input and output files
Members of a structure of type DISTILLRECORD (defined in distctrl.h) are set to specify the list of files to distill and the destination for the output files. Applications should fill in the structure members listed in the following table.
Members of the DISTILLRECORD structure
fileList, specify a directory rather than a specific file, or each destination file will be overwritten by the next.data-id=determining-use-of-the-save-dialog-box
Determining use of the Save dialog box
One of the options listed in the following table must be specified in the SendMessage call to control the appearance of the Save dialog box when each source file is processed.
EnqueueOption constants
data-id=processing-the-file-list
Processing the file list
To instruct Distiller to begin processing the file list, a COPYDATASTRUCT containing the DM_DISTILL message and a pointer to a filled out DISTILLRECORD is sent to Distiller. The following example instructs Distiller to process a PostScript language file and store the resulting PDF file in a specified directory, omitting the unnecessary Save dialog box.
- Processing a file list and omitting the Save dialog box
DISTILLRECORD dr; /* from distctrl.h */
COPYDATASTRUCT cds;
BOOL ok;
LRESULT rtn;
WORD res=0;
char msg[ 80];
hinst = ShellExec( NULL, "acrodist.exe", strCmdArgs, NULL, SW_SHOW);
if (res<32){
sprintf(msg, "WinExec failed: error code = %d", res);
return;
}
CWnd *hDistillerCWnd = FindWindow("Distiller", NULL);
if (hDistillerCWnd != NULL)
{
strcpy(dr.outputFile, "c: OUT.PDF");
strcpy(dr.fileList, "C: TEST.PS");
dr.param = EQ_NO_SAVE_DIALOG;/* from distctrl.h */
cds.dwData = DM_DISTILL;
cds.cbData = sizeof(DISTILLRECORD);
cds.lpData = (PVOID)&dr;
ok = (BOOL)hDistillerCWnd->SendMessage(WM_COPYDATA,
(WPARAM)m_hWnd, (LPARAM)&cds);
if (ok)
/* wake up Distiller */
hDistillerCWnd->PostMessage(WM_TIMER, ID_TIMER, 0L);
}
If the sending application is specified in the WPARAM parameter of the SendMessage call, a WM_COPYDATA message is returned to the application after each file specified has been distilled. The LPARAM parameter of this WM_COPYDATA message will contain a COPYDATASTRUCT that will include a Distiller DM_DONE message and a pointer to a structure of type DISTILLRECORD. The fileList member of the structure contains the name of the PostScript language file that was processed, and the outputFile member contains the name of the resulting PDF file.
data-id=determining-the-version-number
Determining the version number
To determine the Distiller program version number, send a COPYDATASTRUCT containing the DM_VERSION message to Distiller. The Distiller version number will be returned in the return value. The high word has the major version information and the low word has the minor version information.
- Obtaining the Distiller version number
COPYDATASTRUCT cds={0};
DWORD dwVersion;
CWnd *hDistillerCWnd = FindWindow("Distiller", NULL);
if (hDistillerCWnd != NULL)
{
cds.dwData = DM_VERSION;
cds.cbData = 0;
cds.lpData = NULL;
dwVersion = (DWORD)hDistillerCWnd->
SendMessage(WM_COPYDATA,NULL,(LPARAM)&cds);
if (HIWORD(dwVersion) >= 6)
; //6.x and above; LOWORD(dwVersion) has the minor version number.
else
; // Distiller 5.x and below
}
The distctrl.h file for 32-bit Windows is different from the one for 16-bit Windows since the WM_COPYDATA message and COPYDATASTRUCT structure are not defined for 16-bit Windows. Make sure you use the correct distctrl.h for your application.
data-id=passing-in-command-lines
Passing in command lines
In addition to the old WM_COPYDATA interface that uses the limited DISTILLRECORD structure, the newer WM_COPYDATA interface simply lets you pass a command line. This way you can use any of the command line options, such as /J to specify the Adobe PDF settings file (which the old WM_COPYDATA interface does not allow).
Using the new WM_COPYDATA interface is similar to the old, except you create a command line string instead of a data structure.
- Creating a command line string
char szCmdLine[] = "/O outfile.pdf /J myoptions.joboptions infile.ps"
COPYDATASTRUCT cds;
cds.dwData = DM_CMDLINE;
cds.cbData = strlen(szCmdLine) + sizeof(char);
cds.lpData = szCmdLine;
SendMessage( hwndDistiller, WM_COPYDATA,
(WPARAM)hwndMyWindow, (LPARAM)&cds );
- Getting the Distiller version number
To get the Distiller version number, a COPYDATASTRUCT containing the DM_VERSION message is sent to Distiller.
COPYDATASTRUCT cds = {0};
cds.dwData = DM_VERSION;
DWORD dwVersion = SendMessage( hwndDistiller, WM_COPYDATA,
WPARAM)hwndMyWindow, (LPARAM)&cds );
data-id=command-line-options
Command line options
Distiller 6.0 and above support command line and WM_COPYDATA interfaces and add the --deletelog and --nosecurity switches. Options can be passed as arguments on the command line.
The command line syntax is:
acrodist [switches] [inputFiles]
If any switches are present, they must come before any input files. Switches and input file names are both optional. The command acrodist by itself runs Distiller, or if a normal instance of Distiller is already running, it brings Distiller to the foreground.
The switches parameter is a list of optional commands. Either the dash (-) or slash (/) character can begin a switch, which is identified by a single case-independent letter. (Note, however, that the deletelog and nosecurity switches can only be preceded by a double dash (–).) There should be a space after the switch letter, and if the switch takes a parameter, another space after the parameter. The parameter should be in quotes if it contains any spaces. Do not combine switches—give each one its own prefix (- or /).
The parameter inputFiles is a list of file names, separated by spaces or commas. Spaces and commas are both legal file name characters; if a file name contains spaces or commas, enclose it in double quotes.
To process a list of PostScript files, use this syntax:
acrodist [switches] inputFiles[, inputFiles...]
The following table lists the optional command line switches.
Command line switches
--deletelog:on turns on logging for the generated PDF. --deletelog:off turns off logging for the generated PDF."High Quality" "High Quality.joboptions"/F switch permits the PostScript file operators unlimited file access. > Caution > > Enabling unlimited file access can pose security problems. For Acrobat Distiller 5.0 through 8.0, the /F switch restricts PostScript file operators to fonts, color profiles, and other system resources needed for normal operation. Regardless of the /F switch, all versions of Acrobat Distiller can access fonts, color profiles, and other system resources needed for normal operation."High Quality" "High Quality.joboptions"start command with the /wait option. The command “start /Wait “ negates the effect of using /N with Distiller.WM_COPYDATA message or through the COM interface. If it is used as a command line option, then the PDF file (from the command line PostScript stream) will not have any security. But if the user drags and drops another PostScript file from the user interface, then the security settings in the registry will be applied; this is the reason to show the Confirm Security dialog box./N); otherwise idle time is limited by the watched folder timer. If /N is also used, Distiller quits after processing all files on the command line. If /N is not used, Distiller quits after processing all PostScript files in watched directories and any that were specified on the command line. To force Distiller to terminate when it has finished distilling all PostScript files in watched directories and any that were specified on the command line, use this syntax: acrodist /q [sourceFile1[, sourceFile2…]] /Q also accepts an optional timeout value in seconds, /Q:n. Use the timeout to instruct Distiller to wait for n seconds of idle time before exiting. n must be a positive integer and cannot be greater than 2147483 seconds (Ox7fffffff/1000), or about 24.8 days. The default watched folder timer is set to 10 seconds, so every 10 seconds Distiller wakes up to check the watched folder. Since it is checking every 10 seconds, it is idle for no more than 10 seconds. If the SetTimer value is less than 10 seconds, then the system rounds this value to 10 seconds.data-id=disabling-prompts-for-output-file-names
Disabling prompts for output file names
Distiller prompts for output file names based on settings that can be managed with a user interface or by programmatic control.
data-id=turning-prompting-off-for-the-current-user
Turning prompting off for the current user
Prompting can be turned off for the current user for all Adobe PDF document creation regardless of the application using the Adobe PDF printer.
- To turn prompting off for the current user:
- From the Windows Start menu, click Control Panel and open Printers and Faxes folder.
- Right click on Adobe PDF printer and select Printing Preferences from the context menu. Select the default document folder from Adobe PDF Output Folder menu, or click the Browse button to create your own output folder.
- Click OK.
Prompting can be turned off for the current user for Adobe PDF document creation using the Acrobat Distiller.
- To turn prompting off for the current user using Distiller:
- Start Acrobat Distiller, from the Distiller menu choose File > Preferences.
- In the Preferences - Acrobat Distiller dialog box, deselect the Ask for PDF file destination option.
- Click OK.
data-id=customizing-deployment-options-to-turn-off-prompting
Customizing deployment options to turn off prompting
You can disable prompts via the Customization Wizard for Windows prior to application deployment
data-id=programmatic-control
Programmatic control
Prompting can be turned off programmatically by adding a key to the Windows registry. This method applies to the creation of only one PDF document by a specific application for the current user. To use this method, add the following registry key:
HKEY_CURRENT_USERSoftwareAdobeAcrobat DistillerPrinterJobControl
This key takes as subkeys:
(Default)
application
The (Default) entry is reserved for possible future use and is not to be used.
The application subkey is the full path of the application for which prompting is to be turned off. The value of the application subkey is a REG_SZ value that is the full path of the output file. For example, the following registry script would turn off prompting for the next printing performed by wordpad.exe, printing to the file c:MyPDFoutputFileName.pdf :
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USERSoftwareAdobeAcrobat DistillerPrinterJobControl]
"C:Program FilesWindows NTAccessorieswordpad.exe" =
"c:MyPDFoutputFileName.pdf"
Note
Though the programming language may require that your backslashes are escaped (for example,
"c:MyPDFoutputFileName.pdf"), the value of the registry entry must use single slashes. This key, once established, remains until used and is removed once the Windows API functionStartDoc(HDC hdc, CONST DOCINFO* lpdi)has successfully completed. Also note that the output folder path must already exist with read and write access for the current user and the destination file must not exist.