Tips & Tricks

Printing PDFs using JavaScript in Acrobat 6.0

January 21, 2004

Advertisement
Advertisement
 

Included in Acrobat 6.0 is a new JavaScript object that provides more feature-rich printing capabilities from Acrobat JavaScript. This object is known as the printParams object. It should also be noted that this object is not supported in earlier (pre v6.0) versions of Acrobat and Reader, and that some of these properties are only available with the full version of Acrobat 6.0, and not the free Reader.

The way you use the printParams object is that you first must retrieve the object by using the doc.getPrintParams() method that returns the object.

var objPrintParams = this.getPrintParams();

Now that you have the printParams object stored in the objPrintParams variable, properties of the object can be set. A full list of these properties can be found in the Acrobat JavaScript Reference Guide, however we'll mention a few of these here.

  • interactive: Determines the level of interaction between the user and the print job. Set through the constants object.
  • printerName: Allows a specific printer to be selected to print to.
  • pageSubset: Can choose to print all pages, or all even/odd pages.
  • printContent: Choose whether to print just the document content, document content *and* comments or to only print the contents of just the form fields.

Here shows an example of setting the above properties and printing the PDF document.

var objDoc = this;
var objPrintParams = doc.getPrintParams();

// Set so no dialog box is displayed at all to the user during printing
objPrintParams.interacitve = 
objPrintParams.constants.interactionLevel.silent;

// Select which printer to print to
objPrintParams.printerName = "Canon Bubble-Jet BJC-6000";

// Print only odd pages
objPrintParams.pageSubset = objPrintParams.subsets.odd;

// Print both content and comments
objPrintParams.printContent = 
objPrintParams.constants.printContent.docAndComments;

// Print the PDF using properties just set with printParams object
objDoc.print(objPrintParams);

As mentioned above, there are a number of additional properties available in the printParams object -- the Acrobat JavaScript Reference should be consulted for more information.

Related Products at PDF Store

Nitro PDF Professional

Nitro PDF Professional, your PDF creation and editing product. Priced at $99, Nitro PDF Pro is the m... View full product details
Download free demo

PitStop Professional

The industry standard that combines preflight, interactive editing and automated correction capabili... View full product details
Download free demo

Adobe? Acrobat? & PDF Software

The No.1 PDF and Acrobat software store for tools to create, edit and publish PDF files. Get Nitro P... View full product details
Download free demo

PDF In-Depth Free Product Trials Ubiquitous PDF

Nitro PDF Professional

the perfect PDF product for business and enterprise, combining an extremely competitive price with a...

Download free demo

XpdfViewer

This ActiveX control (OCX) provides a PDF file viewer component, enabling developers to add PDF viewing...

Download free demo

Ubiquitous PDF: PDF eBooks-Library

If you are looking for a good store of PDF content, you could do a lot worse than visiting eBooks-Library.com...

September 03, 2009
Search Planet PDF
more searching options...







Download PDF Creator

Download The Best of Planet PDF volume 2
Planet PDF Newsletter
Most Popluar Articles
Features

Collating PDFs using JavaScript

Despite the numerous benefits, there can be potential issues with the conversion of paper documents into electronic archives. When scanning paper pages into PDF, it's possible to end up with the odd- and even-numbered pages in separate PDF files. It can be very time-consuming to collate them manually, but there is an easier way. Sean Stewart explains.

Featured Product

BCL easyPDF SDK

BCL easyPDF SDK is a set of PDF Programming Libraries designed specifically to help Software Developers / Programmers build and deploy enterprise class PDF applications for corporate wide PDF...

Platinum Sponsor
Create & Edit PDF - Nitro PDF Software

ARTS PDF

Silver Sponsors

PDF-Tools enfocus

QuickPDF: The Unrivaled PDF Developer Toolkit