Distiller APIReference
Distiller APIReference
bc Reference
August 2002
Copyright 2002 Adobe Systems Incorporated. All rights reserved.
NOTICE: All information contained herein is the property of Adobe Systems Incorporated. No part of this publication (whether in
hardcopy or electronic form) may be reproduced or transmitted, in any form or by any means, electronic, mechanical, photocopying,
recording, or otherwise, without the prior written consent of the Adobe Systems Incorporated.
PostScript is a registered trademark of Adobe Systems Incorporated. All instances of the name PostScript in the text are references to
the PostScript language as defined by Adobe Systems Incorporated unless otherwise stated. The name PostScript also is used as a
product trademark for Adobe Systems’ implementation of the PostScript language interpreter.
Except as otherwise stated, any reference to a “PostScript printing device,” “PostScript display device,” or similar item refers to a printing
device, display device or item (respectively) that contains PostScript technology created or licensed by Adobe Systems Incorporated
and not to devices or items that purport to be merely compatible with the PostScript language.
Adobe, the Adobe logo, Acrobat, the Acrobat logo, Acrobat Capture, Acrobat Catalog, Acrobat Reader, Acrobat Search, Distiller,
PostScript, and the PostScript logo are trademarks of Adobe Systems Incorporated.
Apple, Macintosh, Power Macintosh, and carbon are trademarks of Apple Computer, Inc., registered in the United States and other
countries. PowerPC is a registered trademark of IBM Corporation in the United States. ActiveX, Microsoft, Windows, and Windows NT
are either registered trademarks or trademarks of Microsoft Corporation in the United States and other countries. UNIX is a registered
trademark of The Open Group. All other trademarks are the property of their respective owners.
This publication and the information herein is furnished AS IS, is subject to change without notice, and should not be construed as a
commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or
inaccuracies, makes no warranty of any kind (express, implied, or statutory) with respect to this publication, and expressly disclaims
any and all warranties of merchantability, fitness for particular purposes, and noninfringement of third party rights.
Documentation Roadmap
Acrobat Search
API Reference
Acrobat Spelling
API Reference
Acrobat Weblink
API Reference
PDF Consultant
(Scrubber)
Adobe Dialog
Manager Reference
Contents
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Other Useful Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Conventions Used In This Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
bShowWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
bSpoolJobs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Contents
This technical note covers two main topics:
● Distiller API methods for Apple Event Support and Windows Messaging. The
Macintosh subsection describes the Distiller API methods available through
AppleScript. This section also discusses the Distiller API methods that are used
with Windows messaging.
● Acrobat Distiller Automation. (Acrobat 4.0 and higher versions) This section
describes the Automation methods available for Distiller.
NOTE: In this document, references to documents that appear online (in blue, italics)
are live links. However, to activate these links, you must install the documents
on your local file system in the same directory structure in which they appear in
the Acrobat SDK. This happens automatically when you install the SDK.
If for some reason you did not install the entire SDK and you do not have all the
documents, please visit the Adobe Solutions Network Web site at
http://partners.adobe.com/asn to find the documents you need. Then install
them in the appropriate directories. You can use the Acrobat SDK
Documentation Roadmap located at the beginning of this document as a guide.
Open
open sourceFile [destination destfile] [joboptions file]
[hide boolean] [openpassword string] [changepassword
string] [printing boolean] [changing boolean]
[selecting boolean] [notechanging boolean] [with wait]
Description
Opens one or more files for the Distiller program to process. If the optional with
wait is used, the Distiller program returns control only after a PDF file (or log file) is
created, instead of immediately. Multiple source and destination files may be
specified.
Setting this to true will cause Distiller to wait for the file(s) to finish distilling before
allowing this Apple event to succeed. (Do not bring Distiller to the foreground or you
will not get proper completion notification.)
The open Apple event supported by the Distiller program is an enhanced version of
the open Apple event.
Parameters
Return Value
None
Example
open "report.ps" destination "mayreport.pdf"
joboptions "MyDisk:Adobe
Acrobat 4.0:Distiller:Settings:PrintOptimized.joboptions"
openPassword "MyPassword" changePassword "MyPassword" with wait without
printing
Run
run
Description
Launches the Distiller program and invokes its standard startup procedures.
Parameters
None
Return Value
None
Example
run
Quit
quit
Description
Terminates the Distiller program.
Parameters
None
Return Value
None
Example
quit
Windows Messaging
The Microsoft® Windows® version of the Distiller program supports two Windows
messages that:
● Specify the file or files to process and the output destination.
● Confirm when each file specified in the first Windows message has completed
processing.
The enumerated data types and constants necessary to use the Windows messaging
portion of the Distiller control interface are defined in the file distctrl.h. This file is
included in the Acrobat Software Development Kit (SDK). Source files that use the
Distiller control interface must include distctrl.h.
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 Table 3.1.
One of the options listed in Table 3.2 must be specified in the SendMessage call to
control the appearance of the Save dialog box when each source file is processed.
Constant Description
EQ_NO_SAVE_DIALOG Do not display the Save dialog box.
EQ_DEFAULT_OLD_DEST Display the Save dialog box. Use the most recent
destination directory as the default destination
directory.
Constant Description
EQ_DEFAULT_SOURCE Display the Save dialog box. Use the source file’s
directory as the default destination directory.
To tell the Distiller program to begin processing the file list, a COPYDATASTRUCT
containing the DM_DISTILL message and a pointer to a filled out DISTILLRECORD
needs to be sent to the Distiller program. The following example tells the Distiller
program to process a PostScript language file and store the resulting PDF file in a
specified directory, omitting the unnecessary 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.
The distctrl.h file for Windows 32-bit is different from the one for Windows 16-bit
since the WM_COPYDATA message and COPYDATASTRUCT structure are not defined
for Windows 16-bit. Make sure you use the correct distctrl.h for your application.
In addition to the old WM_COPYDATA interface that uses the awkward and limited
DISTILLRECORD structure, there is a new WM_COPYDATA interface that simply lets
you pass a command line. This way you can use any of the command line options,
such as /J to specify the job options 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. An example:
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 );
In Table 3.3, “Command Line Switches” the optional command line switches are
listed.
Switch Description
/E [jobOptionsFilePath] Opens Distiller’s Job Options dialog to edit the specified Job
Options file. If you give the filename with no path, Distiller looks
in its Settings folder for the file. If you omit the filename,
Distiller uses the current default Job Options file.
This switch may not be combined with any other command line
options. Distiller will not process any PostScript files and does
not display its main window. It just opens the Job Options dialog
and exits when you close that window.
/F (Distiller 5.0 and higher) Restricts the PostScript file operators
(see Section 8.1, “Operator Summary,” page 518, in the
PostScript Language Reference, third edition) to read-only
access to all directories and files in the Distiller installation
directory with the exception that write access is allowed in the
temporary and hostfont cache directories. For example, if
Distiller’s installation directory is:
C:\Programs\Adobe\Acrobat5.0\Distiller\
then the temporary directory is:
C:\Programs\Adobe\Acrobat5.0\Distiller\Tmp\
${PID}
where {PID} is the process ID of Distiller, and the hostfont
cache directory is:
C:\Programs\Adobe\Acrobat5.0\Distiller\Cache\
Without using this /F command line switch, there is no change
in functionality: a PostScript program will be able to freely use
all the file operators.
/J [jobOptionsFilePath] Uses jobOptionsFilePath as the Job Options file for any
input files specified on the command line. Does not affect any of
the Job Options settings you can set with the UI.
/N Runs a new instance of Distiller, even if another Distiller is
already running. (Without this switch, Distiller switches to any
“normal” previous instance.) The Distiller instance created with
this switch does not process watched folders and is marked so
that it will not get activated by other “normal” Distillers that get
launched later.
Switch Description
/O outputFileOrFolderPath Specifies the output PDF file name or a directory name to put
PDF files in. If you give a directory name, Distiller uses the input
filename for each input file. To process a PostScript language
file and name the output PDF file:
acrodist /o destFile sourceFile
To process a list of PostScript language files and place the
output PDF files in a specified directory:
acrodist /o directory sourceFile1[,
sourceFile2...]
/Q (:seconds) Tells Distiller to exit immediately when it becomes idle.
If /N is also used, quits Distiller after processing all files on the
command line. If /N is not used, quit Distiller after processing
all PostScript language files in watched directories and any that
were specified on the command line.
To force the Distiller program to terminate when it has finished
distilling all PostScript language files in watched directories and
any that were specified on the command line:
acrodist /q [sourceFile1[, sourceFile2...]]
/Q also accepts an optional timeout value in seconds, "/Q:n".
Use the timeout to tell Distiller to wait until n seconds of idle
time before exiting.
/V Forces Distiller to view or not view the generated PDF, as
described below:
/V or /V:on Turns on viewing of the generated PDF, but
viewing can be turned off either later in the command line or in
the user interface.
/V:off Turns off viewing of the generated PDF, but viewing
can be turned on either later in the command line or in the user
interface.
/V- Turns off viewing permanently in this instance of Distiller.
N O T E : /v can
be substituted for /V throughout, but on and off
are case sensitive:ON and OFF will not work.
Introduction
The previous chapters in this document described two ways to automate Distiller:
● WM_COPYDATA interface
● Command line interface
The WM_COPYDATA interface provides compatibility for older applications only. It
works exactly as before, and you cannot use any of Distiller’s new features such as
job options files and input piping through it.
For new applications, the best way to automate Distiller under Microsoft Windows is
through the new Automation interface also known as OLE Automation (commonly
referred to as ActiveX® or COM). The Automation interface makes it easy to create
and control a Distiller from any programming language that supports Automation. We
support programming environments written in:
● Visual Basic
● Visual C++ with and without MFC
Distiller Automation
Distiller exposes one interface: PdfDistiller. This interface provides methods,
properties and events. Unless noted, all examples use Visual Basic notation.
Example
In Visual Basic, if you want to just create and use a Distiller without spooling or events,
the code can be as simple as:
Dim pdf As PdfDistiller
pdf.FileToPdf "My Test File.ps", "", ""
Contents
The remainder of this document contains the following reference chapters:
● Automation Methods. This section describes of each Automation method, including
its parameters, return value, and related methods.
● Automation Properties. This section details the properties that can be set in the
various objects. Each property describes the key, the property type (for example,
read-only), and the semantic.
● Automation Events. As it processes each job, Distiller fires several events to notify
you of its progress. This section describes these events.
Create
Description
Creates a Distiller instance. You do not need to call this method; a Distiller instance is
always created if one of the other methods needs it. You may want to call this if you
are handling events and want to display Distiller’s startup messages before you
submit any jobs.
Each user of the Automation interface gets its own Distiller instance. There is no
sharing of a common Distiller as was done with Distiller 3.0 and the WM_COPYDATA
interface.
Parameters
None
Return Value
None
Exceptions
None
F i l e To P D F
Description
Submits a PostScript file job to the Distiller.
Parameters
strJobOptions The name and path of the Job Options file to use.
Return Value
None
Exceptions
None
bShowWindow
[get/set] As Long
Description
Specifies whether Distiller opens with the status windows. This property takes
effect only if you set it before calling the Create method or any other method.
If you have already started Distiller, bShowWindow has no effect.
bSpoolJobs
[get/set] As Long
Description
Specifies whether Distiller queues PDF jobs through its internal spooler or processes
each job immediately.
By default, bSpoolJobs is false, and FileToPDF processes the PDF job
immediately and does not return until the PDF file is created.
If bSpoolJobs is true, FileToPDF submits the PDF job to Distiller’s internal job
queue and returns immediately. The job will be processed at some later time. To find
out when the job is done, you can watch for the events Distiller runs during job
processing.
OnJobStart
Run once when a job begins processing.
OnJobStart( ByVal strInputPostScript As String,
ByVal_ strOutputPDF As String )
OnJobDone
Run once when a job completes successfully.
OnJobDone( ByVal strInputPostScript As String,
_ByVal strOutputPDF As String )
OnJobFail
Run once when a job ends unsuccessfully.
OnJobFail( ByVal strInputPostScript As String,
_ByVal strOutputPDF As String )
OnLogMessage
Run at various times with the text messages that normally appear in Distiller’s
message log window. The text contains the usual carriage return-line feed pair at the
end of each line. A single call to OnLogMessage may contain multiple lines or partial
lines of text.
OnLogMessage( ByVal strMessage As String )
In the current version of Distiller, the text that is passed in this message may contain
line feed characters without carriage return characters. The application should not
make any assumptions about how this text is formatted and should be prepared to
receive either line feed characters (LF) alone or carriage return - line feed (CR-LF)
pairs.
OnPercentDone
Run periodically during a job to indicate overall progress.
OnPercentDone( ByVal nPercentDone As Long )
OnPageNumber
Run periodically during a job to indicate the current page number.
OnPageNumber( ByVal nPageNumber As Long )