Fix Acrobat JavaScript Changing PDF Page Size After Saving
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.

- 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.
Verify whether your JavaScript is modifying the CropBox, MediaBox, or TrimBox, as conflicting page box dimensions often cause rendering issues upon reopening the PDF.
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.
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.
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.
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.
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.

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. Open your PDF: Launch WPS Office and open the PDF document you want to crop.
- 2. Access the Crop tool: Navigate to the 'Edit' tab on the top ribbon and select the 'Crop Page' option.
- 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. 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.

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.




