How to Correct PDF Page Rotation Using Acrobat JavaScript
Question details
Fix portrait PDF pages that report a 270-degree rotation during a batch JavaScript process without using OCR.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Running a batch Acrobat JavaScript process to add stamps or annotations to PDFs where certain portrait pages have an improper rotation value.
- Observed behavior
- Setting the rotation value to zero changes the page to landscape because of the underlying coordinate system, and JavaScript lacks a simple upright conversion command.
Before running any batch scripts or preflight fixups on your documents, make sure to back up your original PDF files to prevent permanent loss of original formatting.
Normalize Rotation Using Acrobat Preflight Fixup
Use Adobe Acrobat's Preflight tool to permanently correct page rotation and geometry before running your annotation JavaScript.
Because Acrobat JavaScript simply modifies the rotation property of the existing coordinate system, setting a 270-degree page to zero will often flip it horizontally into landscape. Normalizing the document with a Preflight profile rewrites the internal geometry so all pages become upright with a true 0-degree property.
In Adobe Acrobat, navigate to Tools, select Print Production, and then click on Preflight.
Click the wrench icon to view the available Fixups profiles.
Search for 'rotation' or 'page geometry' fixups. Select a profile that normalizes page rotation or permanently sets page orientation, and click 'Fix'.
Once the document is normalized and all pages are upright, execute your batch JavaScript process to apply stamps or annotations without coordinate conflicts.

Use External Command-Line PDF Tools
Process the PDFs through an external command-line tool like Coherent PDF before using Acrobat JavaScript.
Organize and Edit PDF Pages Easily with WPS Office
If managing PDF page coordinates and batch JavaScripts is slowing down your workflow, WPS PDF offers an intuitive interface to easily rotate pages, add annotations, and normalize your documents without writing complex code.
- 1. Open PDF in WPS Office: Launch WPS Office and open your PDF document using the WPS PDF editor.
- 2. Navigate to the Page Tab: Click on the 'Page' tab located in the top navigation menu to view all pages as thumbnails.
- 3. Rotate Pages: Select the pages that need correction and click the 'Rotate Clockwise' or 'Rotate Counterclockwise' buttons to make them upright.
- 4. Add Annotations: Switch to the 'Comment' tab to quickly insert text boxes, stamps, and other annotations exactly where you need them.

Frequently Asked Questions
Why does setting PDF page rotation to zero make my portrait page landscape?
PDF page rotation relies on the document's original coordinate system (MediaBox). If the page was originally created or scanned in landscape mode and then rotated 270 degrees to look like a portrait, setting the rotation property back to zero simply removes that visual adjustment, exposing the original landscape geometry.
Does Acrobat JavaScript have an 'upright' command for PDF pages?
No, Acrobat JavaScript primarily modifies the visual rotation property using functions like setPageRotations(). It does not have a native method to permanently rewrite the internal page geometry or media boxes to simulate an 'upright' command like some external PDF processors do.
Can I permanently change PDF page orientation without using OCR?
Yes. You can permanently alter the orientation by using Adobe Acrobat's Print Production Preflight fixups to normalize page geometry or by processing the file through external command-line tools like Coherent PDF. Neither method requires optical character recognition (OCR) or makes the document searchable.




