IRONSOFTWAREHOME
Portrait & Landscape Orientation

import com.ironsoftware.ironpdf.PdfDocument;  
import com.ironsoftware.ironpdf.edit.PageSelection;  
import com.ironsoftware.ironpdf.page.PageRotation;  
import com.ironsoftware.ironpdf.render.*;  
import java.io.IOException;  
import java.nio.file.Paths;

// Use the setPaperOrientation method to set rendered PDFs in portrait or landscape orientation.  
// Note: This will only work for newly-created PDFs!  
ChromePdfRenderOptions renderOptions = new ChromePdfRenderOptions();  
renderOptions.setPaperOrientation(PaperOrientation.LANDSCAPE);  
PdfDocument newPdf = PdfDocument.renderUrlAsPdf("https://ironpdf.com", renderOptions);  
newPdf.saveAs(Paths.get("assets/LandscapePdf.pdf"));  
  
// Use the rotatePage/rotateAllPages methods to adjust the page orientation for existing PDFs  
PdfDocument existingPdf = PdfDocument.fromFile(Paths.get("assets/example.pdf"));  
  
// Get the orientation of the first page of the existing PDF document.  
PageRotation firstPageRotation = existingPdf.getPagesInfo().get(0).getPageRotation();  
System.out.println(firstPageRotation);  
  
// Rotate the first page of the document only 90 degrees clockwise.  
existingPdf.rotatePage(PageRotation.CLOCKWISE_90, PageSelection.firstPage());  
  
// Rotate all pages of the document clockwise.  
existingPdf.rotateAllPages(PageRotation.CLOCKWISE_270);  
  
existingPdf.saveAs(Paths.get("assets/ExistingPdfRotated.pdf"));
mvn install
Portrait & Landscape Orientation

Portrait & Landscape Orientation

IronPDF for Java can modify the page orientation of new and existing PDF documents.

New PDF documents rendered anew with IronPDF use portrait orientation by default. Developers can override this behavior when converting content (HTML, RTFs, URLs, etc.) into PDFs with a ChromePdfRenderOptions instance. The setPaperOrientation method accepts a PaperOrientation value and allows developers to alter the paper orientation of the resulting PDF as desired. Lines 21 - 23 of the featured code example create a PDF document set in landscape orientation. The call to setPaperOrientation with PaperOrientation.LANDSCAPE on line 21 triggers the orientation behavior. Substituting the enum value in favor of PaperOrientation.PORTRAIT would make the subsequent call to PdfDocument.renderUrlAsPdf create the IronPDF homepage in portrait orientation.

ChromePdfRenderOptions objects cannot be used to change the page orientation for existing PDFs (these can be PdfDocuments produced from previous calls to any of the PDF rendering methods or that have been loaded into IronPDF using the PdfDocument.fromFile method). For these PDF documents, page orientation can be adjusted with rotation-based transformations. Towards this end, IronPDF makes the rotateAllPages method available for use.

rotateAllPages accepts a PageRotation enum type, which specifies a set of accepted rotation values. Line 40 of the featured code example rotates every page in the working PDF document clockwise by 270 degrees. To rotate only one page (or a subset of pages) in a PDF, opt for the rotatePage method in lieu of rotateAllPages.

Learn more about PaperOrientation in IronPDF for Java.
View on GitHub

Ready to Get Started?

Version:2026.8just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
Java Maven Library for PDF
Install with Maven

Version: 2026.8

<dependency>
   <groupId>com.ironsoftware</groupId>
   <artifactId>ironpdf</artifactId>
   <version>2026.8.2</version>
</dependency>
https://central.sonatype.com/artifact/com.ironsoftware/ironpdf/2026.8.2
or
Java PDF JAR
Download JAR

Version: 2026.8

Manually install into your project