IRONSOFTWAREHOME
直式與橫式排版
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
直式與橫式排版

直式與橫式排版

頁面的方向和旋轉有時會混淆,因為在處理90度旋轉和橫向方向時,它們在視覺上看起來相似。

頁面的方向專指頁面如何初始佈局,有兩個選項:垂直(直向)或水平(橫向)。

另一方面,頁面旋轉涉及調整頁面的角度,允許您根據需要更改頁面的方向。 這對於校正對齊或滿足特定的觀賞偏好很有用。 頁面角度通常可以設置為90、180或270度。

了解更多關於在PDF渲染過程中配置頁面方向的方法,請參閱IronPDF的設定頁面方向指南。 然而,在現有的PDF文件中無法更改頁面的方向。 相反地,可以對現有的PDF文件應用旋轉,但無法在渲染過程中調整。

在GitHub上探索我們的PDF頁面方向範例
在 GitHub 上查看

準備好開始了嗎?

版本:2026.6剛剛發布

Key in blue circle

立即免費取得 30 天試用金鑰

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
預訂您的免費線上演示
Booking Badge

獲得來自全球數百萬工程師的信賴

Iron Software的客戶徽標
獲取您的無義務諮詢
填寫以下表格或發送電子郵件至sales@ironsoftware.com
您的資料將始終保密。
獲得來自全球數百萬工程師的信賴
Iron Software的客戶徽標
立即獲取您的30天試用金鑰
無需信用卡或帳戶建立