PDF Editing Issues

Crop Multiple PDF Pages with Acrobat JavaScript

Bushra ParveenBushra Parveen Nov 24, 2026 868 views

Question details

Apply an Acrobat JavaScript page-box change to multiple pages in a PDF.

Crop Multiple PDF Pages with Acrobat JavaScript
Product
Adobe Acrobat JavaScript
Device & OS
not provided
Scenario
A script uses setPageBoxes to crop or shift page boundaries in a multipage PDF.
Observed behavior
The script changes only the current page because both the starting and ending page are set to this.pageNum.
Before you start

Open the PDF in Acrobat and check whether the pages have consistent dimensions and orientation. Identify the crop rectangle your script should apply; page numbers in Acrobat JavaScript are zero-based.

Solution 1Recommended

Set the Acrobat JavaScript page range to cover the PDF

Use this method to apply the same crop rectangle to every page or to a selected range.

The setPageBoxes method applies one rectangle to every page in the specified range. If pages have different sizes or orientations, check the results or calculate a suitable rectangle for each page.

Changing the CropBox changes the visible page boundary; it does not move the underlying page content.

1
Open the JavaScript console

Open the PDF in Acrobat, then press Ctrl+J on Windows or Command+J on macOS to open the JavaScript console.

2
Change the page range

In your existing setPageBoxes call, replace nStart: this.pageNum with nStart: 0 and nEnd: this.pageNum with nEnd: this.numPages - 1. Keep the intended cBox and rBox values from your script.

3
Run the updated script

Select the updated code in the console and press Ctrl+Enter on Windows or the numeric keypad Enter key. For a smaller range, use zero-based values for nStart and nEnd; for example, 1 and 3 apply the change to pages 2 through 4.

4
Check the pages

Scroll through the affected pages in Acrobat and verify that the boundaries are correct before choosing File > Save.

Set the Acrobat JavaScript page range to cover the PDF
Use the document page count: The last page is this.numPages - 1, not this.pageNum - 1. The latter refers to the page before the current page.
Crop PDF pages without scripting

Crop multiple PDF pages in WPS Office

Use the PDF crop tool in WPS Office to adjust visible page boundaries without writing Acrobat JavaScript. Tool availability and page-range options may vary by version or plan.

  1. 1. Open the PDF: Launch WPS Office and choose Open to select your PDF.
  2. 2. Find the crop tool: In the PDF toolbar, look for Crop Pages or Crop under the page-editing tools.
  3. 3. Set the crop and range: Adjust the crop boundary, then select the desired pages or all pages in the page-range options, if available.
  4. 4. Apply and review: Click Apply and check the affected pages before saving the PDF.
Apply a crop visually to PDF pages without JavaScriptWork with PDF files and Microsoft Office formats such as DOCX and XLSXUse a familiar interface for document and PDF tasks
microsoft office alternative - wps office

Frequently Asked Questions

Why does my script crop only the visible page?

If both nStart and nEnd are this.pageNum, setPageBoxes targets only the current page. Set nStart to 0 and nEnd to this.numPages - 1 to target the whole document.

How do I crop only pages 2 through 4?

In the setPageBoxes call, set nStart to 1 and nEnd to 3. Acrobat JavaScript page indices start at zero, and both endpoints are included.

Does changing the CropBox move text or images?

No. Changing the CropBox adjusts the visible boundary rather than moving the underlying content. Moving content requires a different editing operation.

Can I use the same crop rectangle on pages of different sizes?

You can pass one rBox value to a range, but it may not produce the intended result on pages with different dimensions or orientations. Check each page or calculate a separate rectangle for each page.

Can WPS Office run my Acrobat setPageBoxes script?

WPS Office provides PDF editing tools, but its visual crop workflow does not run Acrobat's setPageBoxes JavaScript API. Use Acrobat for that script or use WPS's crop tool to adjust page boundaries visually.