Apache PDFBox - Rotate Pages
π§ Operation Name
Apache PDFBox - Rotate Pages
rotatePages
π§Ύ Description
Rotates one or more pages in a PDF document clockwise by 90, 180, or 270 degrees. You can optionally limit the rotation to specific pages using a page range.
β
Inputs
PDF File [Binary]
InputStream
(Binary)
β
The PDF file to rotate.
Degrees
Integer
β
The rotation angle: must be one of 90
, 180
, or 270
.
Page Range
String
β (Optional)
A comma-separated list of pages and/or ranges to rotate (e.g., 1,3,5-6
). If not provided, all pages will be rotated.
π€ Output
Payload:
InputStream
(Binary) A new binary PDF stream with the specified pages rotated.Attributes:
PdfBoxFileAttributes
Includes original PDF metadata such as:numberOfPages
title
,author
, etc.
π§ͺ MuleSoft Flow Example
Hereβs how to call this operation in a MuleSoft flow:
This example uses both Filter and Rotate as our test pdf is password protected so we use a filter to effectively make a copy

<mule
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:pdfbox="http://www.mulesoft.org/schema/mule/pdfbox"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/pdfbox
http://www.mulesoft.org/schema/mule/pdfbox/current/mule-pdfbox.xsd
http://www.mulesoft.org/schema/mule/file
http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
<flow name="main">
<scheduler doc:name="Scheduler" doc:id="dsgkfy" >
<scheduling-strategy>
<fixed-frequency timeUnit="HOURS"/>
</scheduling-strategy>
</scheduler>
<flow-ref name="Apache PDFBox - Rotate Pages" />
</flow>
<sub-flow name="Apache PDFBox - Rotate Pages">
<set-payload doc:id="vxsfk4" doc:name="Set payload" mimeType="application/octet-stream" value='#[%dw 2.0
output application/java
---readUrl("https://www.adobe.com/support/products/enterprise/knowledgecenter/media/c4611_sample_explain.pdf", "application/octet-stream") as Binary]'></set-payload>
<pdfbox:filter-pages doc:name="Apache PDFBox - Filter Pages" doc:id="fryjll" removeBlankPages="YES"/>
<pdfbox:rotate-pdf-pages rotationAngle="ROTATION_90" doc:name="Apache PDFBox - Rotate Pages" doc:id="gvirqt" pageRange="2"/>
<logger doc:name="Logger" doc:id="ecdqs4s" message='#[%dw 2.0
output text
---
"\n\n Apache PDFBox - Rotate Pages"
++ "\n\nββββββββββββββββββββ"
++ "\n\nRotate Pages Attributes: " ++ (write(attributes, "application/json")) as String
++ "\n\n^^^^^^^^^^^^^^^^^^^^"
++ "\n\n Apache PDFBox - Rotate Pages"
++ "\n\n"]'/>
<file:write path="test.pdf" doc:name="Write" doc:id="edxzk4" />
</sub-flow>
</mule>
π Notes
Degrees must be one of:
90
,180
, or270
. Other values will trigger a validation error.If
pageRange
is omitted, all pages will be rotated.Rotation is applied clockwise from the current orientation.
Useful for correcting scanned documents or preparing them for display.
Underlying Application Interface:
Last updated