PDF Printing Issues

How to Print PDF Pages to Different Printers Using JavaScript

Chanuka GeekiyanageChanuka Geekiyanage Nov 2, 2026 869 views

Question details

The user wants to programmatically route specific PDF pages to different printers based on their page size (e.g., sending A1 pages to a plotter and A2 pages to a standard printer) using JavaScript.

How to Print PDF Pages to Different Printers Using JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Automating the printing process of a mixed-size PDF document by sending specific page ranges to designated physical printers.
Observed behavior
Looking for the correct JavaScript methods and objects to define page ranges and assign them to specific printer names without splitting the document manually.
Before you start

Ensure you know the exact system names of your target printers and verify that your PDF application's security settings permit JavaScript execution for print commands.

Solution 1Recommended

Use the PrintParams Object in Acrobat JavaScript

Configure the PrintParams object to define specific page ranges and assign them to distinct printer names programmatically.

In Adobe Acrobat, you can automate printing tasks using the Document object's print method combined with the PrintParams object. This allows you to specify exactly which pages go to which printer. Keep in mind that Acrobat JavaScript uses zero-based indexing, meaning the first page of your PDF is considered page 0.

1
Initialize the PrintParams object

Open your document-level script editor or JavaScript console. Create a variable to retrieve the printing parameters by typing: var pp = this.getPrintParams();

2
Set the first target printer

Assign the exact name of your first printer to the object by using: pp.printerName = "My Printer 1"; (replace "My Printer 1" with your actual printer name).

3
Define the first page range

Set the starting and ending pages for this printer. For example, to print pages 1 through 5, use: pp.firstPage = 0; and pp.lastPage = 4;.

4
Execute the first print command

Call the print method using your configured parameters by typing: this.print(pp);

5
Configure and print to the second printer

Update the parameters for the next batch of pages. Set pp.printerName = "My Printer 2";, update the firstPage and lastPage values (e.g., 5 and 9 for pages 6-10), and call this.print(pp); again.

Use the PrintParams Object in Acrobat JavaScript
Handling Dialogs: If you need to show confirmation dialogs in your script, always use app.alert rather than the standard browser confirm() method, as Acrobat's environment requires its own UI methods.

Easily Print Specific PDF Pages with WPS Office

While JavaScript offers programmatic control for complex workflows, WPS Office provides an intuitive user interface to quickly print specific page ranges or sizes to any connected printer without writing a single line of code.

  1. 1. Open your PDF: Launch WPS Office and open the PDF document containing the mixed page sizes.
  2. 2. Access the Print Menu: Press Ctrl + P or click on Menu in the top left corner, then select Print.
  3. 3. Select Target Printer: In the Printer drop-down menu, select the specific printer you want to use for your first batch of pages.
  4. 4. Define Page Range: Under the Page Range section, choose 'Pages' and input the specific page numbers you wish to send to this printer.
  5. 5. Print and Repeat: Click Print. Once finished, repeat the process by selecting your second printer and inputting the remaining page numbers.
No coding knowledge required for customized printingHighly compatible with all standard PDF formats and structuresFree, lightweight, and fast PDF viewer and editorIntuitive printer selection and page range configuration
microsoft office alternative - wps office

Frequently Asked Questions

Why is my JavaScript printing the wrong page numbers?

Acrobat JavaScript uses zero-based indexing for pages. This means page 1 is represented as 0, page 2 as 1, and so forth. Make sure you subtract 1 from your actual document page numbers when setting the firstPage and lastPage properties.

Can I suppress the print confirmation dialog when using JavaScript?

Yes, you can configure the PrintParams object to suppress UI dialogs by setting pp.interactive = pp.constants.interactionLevel.silent. However, depending on the PDF application's security settings, silent printing might require elevated privileges or specific trust settings.

How do I dynamically check the page size before assigning the printer?

You can use the this.getPageBox("Crop", pageIndex) method in a loop to retrieve the dimensions of each page. By evaluating the width and height returned by the array, you can use conditional statements (if/else) to dynamically assign the printerName before calling the print command.