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% 解锁。无需信用卡。

OR
bullet_checked无需信用卡或创建账户无任何限制。100% 解锁。无需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
预约您的免费现场演示
Booking Badge

深受全球数百万工程师信赖

Iron Software 的客户徽标
获取您的无义务咨询
填写下面的表格或通过sales@ironsoftware.com
您的资料将始终保密。
深受全球数百万工程师信赖
Iron Software 的客户徽标
立即获取您的免费30 天试用密钥。
无需信用卡或创建账户
Node.js 模块下载用于 PDF
using npm 安装

版本: 2026.6

  1. 下载并安装 Node.js 12+。
  2. 在终端中执行上述命令。

$999 起