data-id=print-production
Print Production
This chapter will provide you with an in-depth understanding of the ways in which you can manage print production workflows for PDF documents.
data-id=43419
data-id=setting-print-options
Setting print options
Since printing involves sending pages to an output device, there are many options that can affect print quality. JavaScript can be used to enhance and automate the use of these options in print production workflows, primarily through the use of the PrintParams object, whose properties and methods are described in the following table.
PrintParams properties
fileName is used when printing to a file instead of a printer.In addition to the properties of the PrintParams object, the app object’s printColorProfiles and printerNames properties provide a list of available color spaces and printer names, respectively.
When printing a document, any comments and form fields of the document may or may not print, depending on the settings of the individual annotations. The print property of the Annotation and Field objects is used to set whether an individual annotation is printed.
data-id=89379
data-id=printing-pdf-documents
Printing PDF documents
It is possible to use JavaScript to specify whether a PDF document is sent to a printer or to a PostScript file. In either case, to print a PDF document, invoke the Doc object print method. Its parameters are described in the following table.
Print method parameters
printParams parameter is available in Acrobat 6.0 or later. If this parameter is passed, it is passed as a literal object and any other parameters are ignored.In the first example below, pages 1-10 of the document are sent to the default printer, printed silently without user interaction, and are shrunk to fit the imageable area of the pages:
this.print({
bUI: false,
bSilent: true,
bShrinkToFit: true,
nStart: 1,
nEnd: 10
});
The syntax above is used for versions of Acrobat previous to 6.0.
For Acrobat 6.0 or later, the recommend method is to pass a PrintParams object to the Doc.print method. All the subsequent examples use this method.
To print the document to a PostScript file, obtain the PrintParams object by invoking the Doc object getPrintParams method. Set its printerName property to the empty string, and set its fileName property to a string containing the device-independent path of the PostScript file to which it will be printed, as shown in the following example:
var pp = this.getPrintParams();
pp.printerName = "";
// File name must be a safe path
pp.fileName = "/C/temp/myPSDoc.ps";
this.print(pp);
If you would like send the file to a particular printer, you can specify the printer by setting the printerName property of the PrintParams object, as shown in the following example:
var pp = this.getPrintParams();
pp.interactive = pp.constants.interactionLevel.automatic;
pp.printerName = "Our office printer";
this.print(pp);
data-id=69102
data-id=silent-printing
Silent printing
There are various ways to print a document without requiring user interaction. One way is to use the Doc object print method and set the bSilent attribute to true, as the following example shows.
this.print({bUI: false, bSilent: true, bShrinkToFit: true});
Beginning with version 7.0, non-interactive printing can only be done in batch and console events. Using the PrintParams object, this is the script for printing silently:
var pp = this.getPrintParams();
pp.interactive = pp.constants.interactionLevel.silent;
this.print(pp);
If you would like to print without requiring user interaction, and would like the progress monitor and Cancel dialog box to be removed when printing is complete, use the interactive property as shown in the following example:
var pp = this.getPrintParams();
pp.interactive = pp.constants.interactionLevel.automatic;
There are many options you can choose without requiring user interaction. For example, you can select the paper tray:
var fv = pp.constants.flagValues;
pp.flags = fv.setPageSize;
These coding approaches may be used in menus or buttons within a PDF file, may exist at the folder or batch levels, and are available through Acrobat or Acrobat Reader 6.0 or later. For more information, see the Acrobat JavaScript API Reference, as well as the Acrobat SDK samples SDKSilentPrint.js and SDKJSSnippet1.pdf.
data-id=26072
data-id=printing-comments-and-forms
Printing comments and forms
The printContent property of the PrintParams object can be used to control whether document content, form fields, and comments will be printed. In the following example, only the form field contents will be printed (this is useful when sending data to preprinted forms):
var pp = this.getPrintParams();
pp.interactive = pp.constants.interactionLevel.silent;
pp.printContent = pp.constants.printContent.formFieldsOnly;
this.print(pp);
data-id=13332
data-id=booklet-printing
Booklet printing
Beginning with Acrobat 8.0, you can print booklets. To do so, begin by getting the PrintParams object:
var pp = this.getPrintParams();
Then set the pageHandling property to booklet:
pp.pageHandling = pp.constants.handling.booklet;
Use the booklet property of PrintParams to set the specialized printing parameters for booklet printing. pp.booklet is an object with properties:
binding: determines the paper binding direction and the page arrange orderduplexMode: determines the duplex printing modesubsetFrom: determines the first booklet sheet to be printed. Independently from the general page range selectionsubsetTo: determines the last booklet sheet to be printed
All the properties above take integers for their values.
The value for binding is set through the properties of the constants.bookletBindings object of PrintParams, as illustrated in the following example.
- Set up booklet printing for right-side binding of text and print
var pp = this.getPrintParams();
pp.pageHandling = pp.constants.handling.booklet;
pp.booklet.binding = pp.constants.bookletBindings.Right;
this.print(pp);
The constants.bookBindings object has four properties: Left (the default), Right, LeftTall and RightTall.
The value for duplexMode is set through the properties of the constants.bookletDuplexModes object of PrintParams.
- Print booklet in duplex mode, printing only the front pages
pp.pageHandling = pp.constants.handling.booklet;
pp.booklet.duplexMode = pp.constants.bookletDuplexModes.FrontSideOnly;
this.print(pp);
constants.bookletDuplexModes has three properties: BothSides, FrontSideOnly and BackSideOnly. For printers that print only on one side, use FrontSideOnly first then reinsert the printed pages and print again with BacksideOnly to complete a manual duplex printing.
data-id=79684
data-id=setting-advanced-print-options
Setting advanced print options
You can set the properties of the PrintParams object to specify advanced options including output, marks and bleeds, transparency flattening, PostScript options, and font options.
data-id=specifying-output-settings
Specifying output settings
You can obtain a listing of printer color spaces available by invoking the app object printColorProfiles method. You can then assign one of these values to the PrintParams object colorProfile property.
In addition, you can set the flags property of the PrintParams object to specify advanced output settings, such as applying proof settings, shown in the example below:
var pp = this.getPrintParams();
var fv = pp.constants.flagValues;
pp.flags = fv.applySoftProofSettings;
this.print(pp);
data-id=specifying-marks-and-bleeds
Specifying marks and bleeds
You can specify the types of tile marks and where overlap occurs by setting the tileMark property of the PrintParams object. For example, in the following code, Western style tile marks are printed:
var pp = this.getPrintPareams();
pp.tileMark = pp.constants.tileMarks.west;
this.print(pp);
data-id=setting-postscript-options
Setting PostScript options
You can set the flags property of the PrintParams object to specify advanced PostScript settings, such as emitting undercolor removal/black generation, shown in the example below:
var pp = this.getPrintParams();
var fv = pp.constants.flagValues;
pp.flags &= ~(fv.suppressBG fv.suppressUCR);
this.print(pp);
In addition, you can set the psLevel property of the PrintParams object to specify the level of PostScript emitted to PostScript printers. If the printer only supports PostScript level 1, set the PrintParams object’s printAsImage property to true.
data-id=setting-font-options
Setting font options
You can control the font policy by setting the fontPolicy property of the PrintParams object. There are three values that may be used:
everyPage: emit needed fonts for every page, freeing fonts from the previous page. This is useful for printers having a small amount of memory.jobStart: emit all fonts at the beginning of the print job, free them at the end of the print job. This is useful for printers having a large amount of memory.pageRange: emit the fonts needed for a given range of pages, free them once those pages are printed. This can be used to optimize the balance between memory and speed constraints.
These values can be accessed through the constants.fontPolicies object of the PrintParams object. In the following example, all the fonts are emitted at the beginning of the print job, and freed once the job is finished:
var pp = this.getPrintParams();
pp.fontPolicy = pp.constants.fontPolicies.jobStart;
this.print(pp);
You can also control whether Type 1 fonts will be converted to alternative font representations, by setting the useT1Conversion property of the PrintParams object. There are three values that can be used:
auto: let Acrobat decide whether to disable the conversion, based on its internal list of printers that have problems with these fonts.use: allow conversion of Type 1 fonts.noUse: do not allow conversion of Type 1 fonts.
These values are accessed through the constants.usages object of the PrintParams object. In the following example, conversion of Type 1 fonts is set to automatic:
var pp = this.getPrintParams();
pp.useT1Conversion = pp.constants.usages.auto;
this.print(pp);
Finally, it is possible to send Far East fonts to the printer by setting the PrintParams object’s downloadFarEastFonts property to true.