Other PDF Issues

Fix Acrobat JavaScript Changing PDF Page Size After Saving

Ayan MasoodAyan Masood Nov 3, 2026 869 views

Question details

The user is trying to permanently adjust PDF page dimensions using a JavaScript crop script, but the changes do not persist properly after the document is saved and reopened.

How to Fix Acrobat JavaScript Changing PDF Page Size After Saving
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Running an Acrobat JavaScript script to crop or modify the page dimensions of a PDF document.
Observed behavior
The crop script appears to produce the expected page size initially, but the page dimensions revert to the original size or change unexpectedly after saving and reopening the file.
Before you start

Verify whether your JavaScript is modifying the CropBox, MediaBox, or TrimBox, as conflicting page box dimensions often cause rendering issues upon reopening the PDF.

Solution 1Recommended

Troubleshoot Acrobat Page Boxes and Script Execution

Identify if the issue is caused by the difference between MediaBox and CropBox definitions or an incremental save error.

In PDF documents, the physical page size is dictated by the MediaBox, while the visible page area is dictated by the CropBox. If your script only adjusts one of these without synchronizing the other, the PDF viewer may revert to the original dimensions upon reopening.

1
Check the script's box definitions

Review your JavaScript code to ensure you are setting the `CropBox` properly using `this.setPageBoxes()`. Setting only the `MediaBox` might not visibly crop the page depending on viewer preferences.

2
Verify rectangle parameters

Ensure the parameters define the correct rectangle array `[left, top, right, bottom]` in points. Incorrect mathematical inputs can cause the viewer to reject the new dimensions.

3
Perform a 'Save As'

After running the script, go to 'File' > 'Save As' instead of a standard 'Save'. Standard saves are incremental and might not rewrite the page dictionary correctly to enforce the new dimensions.

4
Use Action Wizard

Test the script execution via the Acrobat Action Wizard to ensure it processes the document structure entirely and applies the changes across all specified pages before prompting a save.

Troubleshoot Acrobat Page Boxes and Script Execution
Hidden Data Retention: Keep in mind that altering the CropBox via JavaScript only hides the excluded areas; it does not permanently delete the data or reduce file size.
Crop PDFs Without Scripts

Crop PDF Pages Easily Without Coding Using WPS Office

If Acrobat JavaScript is too complex or produces inconsistent results when saving, you can visually and precisely crop PDF pages using the built-in Crop tool in WPS Office. It saves permanently without any coding required.

  1. 1. Open your PDF: Launch WPS Office and open the PDF document you want to crop.
  2. 2. Access the Crop tool: Navigate to the 'Edit' tab on the top ribbon and select the 'Crop Page' option.
  3. 3. Adjust crop margins: Drag the bounding box handles to set your desired page dimensions, or enter specific margin values in the settings panel.
  4. 4. Apply and Save: Click 'Complete' to apply the crop to the current page or all pages, then click the 'Save' icon to permanently preserve the new dimensions.
Easily crop PDF pages visually without writing complex JavaScript.Changes to page dimensions are permanently saved and highly compatible with other standard PDF viewers.Fully compatible with standard PDF formats exported from Adobe Acrobat and Microsoft Office.Lightweight, fast, and features a user-friendly interface for seamless PDF editing.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my PDF look uncropped after reopening it?

This usually happens because the PDF viewer is defaulting to the MediaBox dimensions instead of the CropBox, or the script changes were saved incrementally and failed to completely overwrite the document's base page dictionary.

What is the difference between MediaBox and CropBox in a PDF?

The MediaBox defines the physical physical size of the page medium, while the CropBox defines the visible region of the page that is displayed or printed. Scripts often need to modify the CropBox for visual changes to take effect.

Can I permanently remove the cropped out areas of a PDF using a script?

Merely setting the CropBox hides the content rather than deleting it. To permanently remove cropped data and reduce the file size, you must use a 'Redact' or 'Remove Hidden Information' tool, as standard cropping scripts do not delete the underlying text and image data.