Skip to content

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.

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 output folder if it doesn’t exist and overwrites the file if it already exists.
ParameterTypeDefaultDescription
pathstring—Path of the source PDF.
outputstring—Path of the resulting PDF.
angleint—Rotation angle in degrees: 90, 180 or 270.
ParameterTypeDefaultDescription
pagesstring | 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.

Returns a string with the path of the PDF created (the same as output).

MessageCause 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 filePassword-protected or damaged PDF. See Protected and damaged PDFs.
PDF Rotate path = filePath output = "C:/fixed.pdf" angle = 90 → output: fixed
PDF Get Text path = fixed → output: text

Turn 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: foundPages
PDF Rotate path = filePath output = "C:/fixed.pdf" angle = 90 pages = foundPages