Portrait & Landscape Orientation
import {PdfDocument, PdfPaperOrientation} from "@ironsoftware/ironpdf";

(async () => {
    const options = {
        // For NEW PDF Documents use PdfPaperOrientation
        // PdfPaperOrientation: To choose Landscape or Portrait Orientation in a new PDF document
        paperOrientation: PdfPaperOrientation.Landscape,
    };
 
    const newPdfFromHtml = PdfDocument.fromHtml("<h1> Hello World! </h1>", {renderOptions: options});
    const newPdfFromHtmlFile = PdfDocument.fromHtml("example.html", {renderOptions: options});
    const newPdfFromUrl = PdfDocument.fromUrl("https://ironpdf.com", {renderOptions: options});
    
    // For EXISTING PDFs use setRotation
    // setRotation : To rotate a PDF page and all of its contents
    const existingPdf = PdfDocument.fromFile("old_report.pdf");

    // Rotate specified page
    (await existingPdf).setRotation(90,{pdfPageSelection: [0]});

    // Rotate ALL pages
    (await existingPdf).setRotation(270,{pdfPageSelection: "all"});
    
    (await existingPdf).saveAs("rotated.pdf");
})();
npm i @ironsoftware/ironpdf
Portrait & Landscape Orientation

Portrait & Landscape Orientation

Page orientation and rotation can sometimes be confused, as they could visually appear similar when dealing with a 90-degree rotation and landscape orientation.

Page orientation specifically refers to how a page is initially laid out, with two options: vertically (portrait) or horizontally (landscape).

Page rotation, on the other hand, involves adjusting the angle of a page, allowing you to change its orientation as needed. This is useful for correcting alignment or meeting specific viewing preferences. Page angles can typically be set at 90, 180, or 270 degrees.

Learn more about configuring page orientation during the PDF rendering process with IronPDF's guide on setting page orientation. However, it is not possible to change the page orientation in an existing PDF document. In contrast, rotation can be applied to an existing PDF document but cannot be adjusted during the rendering process.

Explore Our PDF Page Orientation Example on GitHub
View on GitHub

Ready to Get Started?

Version:2026.11just released