PDF Rotate
PDF Rotate
Section titled “PDF Rotate”Type: pdf-rotate · Package: PDF Activities v1.2.4 · Output: string
Rotates the pages of a PDF by 90, 180 or 270 degrees, and saves the result in a new file. Useful to fix documents scanned upside down or sideways before processing or sending them.
How it works
Section titled “How it works”Rotates the requested pages (all of them, a range or a list of numbers) by the given angle, clockwise, and creates a new PDF at output with all the pages (rotated or not). Returns the path of the file created. The original stays intact.
- The rotation adds up to whatever the page already has: rotating by 90° a page that was already at 90° leaves it at 180°.
- A page that doesn’t exist in the document is an error and no file is created. Since 1.2.4. It used to be ignored.
- It creates the
outputfolder if it doesn’t exist and overwrites the file if it already exists.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Path of the source PDF. |
output | string | — | Path of the resulting PDF. |
angle | int | — | Rotation angle in degrees: 90, 180 or 270. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
pages | string | List | "all" | Pages to rotate: "all", a text range like "1-3,5" or a list of numbers, such as the one returned by PDF Search Text. Since 1.2.4. |
Output
Section titled “Output”Returns a string with the path of the PDF created (the same as output).
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'angle' must be 90, 180, or 270. Received: …. | Another angle, a decimal (90.5) or a non-numeric text. To turn left, use 270. |
Page(s) out of range: …. The document has … pages. | Some requested page doesn’t exist. Since 1.2.4. |
No valid pages were specified. | pages holds no valid number (an empty text or an empty list). Since 1.2.4. |
'pages' must contain whole page numbers; '…' is not one. | The list holds something that isn’t a whole page number. Since 1.2.4. |
File not found. | The path doesn’t exist. |
'path' is required. / 'output' is required. / 'angle' is required. | The parameter was left empty or its expression returned null. |
| PDF library error when opening the file | Password-protected or damaged PDF. See Protected and damaged PDFs. |
Example
Section titled “Example”PDF Rotate path = filePath output = "C:/fixed.pdf" angle = 90 → output: fixedPDF Get Text path = fixed → output: textTurn only pages 2 and 4, which come upside down:
PDF Rotate path = filePath output = "C:/fixed.pdf" angle = 180 pages = "2,4"Rotate the pages where a text appears, with the list from PDF Search Text:
PDF Search Text path = filePath text = "LANDSCAPE" → output: foundPagesPDF Rotate path = filePath output = "C:/fixed.pdf" angle = 90 pages = foundPagesRelated activities
Section titled “Related activities”- PDF Extract Pages — keep specific pages.
- PDF Get Page Count — find out how many pages there are.