IronPDF 操作指南 方向和旋转 How to Set Page Orientation and Rotation Chaknith Bin 已更新:七月 27, 2025 Download IronPDF NuGet 下载 DLL 下载 Windows 安装程序 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English 页面方向指的是页面的布局方式, 可以是垂直(纵向)或水平(横向)。 页面旋转是调整页面的角度, 允许您更改其方向, 这对于校正对齐或满足特定查看偏好非常有用。 页面角度可以设置为90, 180和270度。 IronPDF允许您在渲染过程中将方向指定为纵向或横向。 此外, 您可以根据需要单独将新渲染或现有的PDF页面旋转为0, 90, 180或270度。 快速开始: 在C#中设置PDF页面方向和旋转 使用IronPDF在.NET C#中轻松设置PDF文件的页面方向和旋转。 首先加载您的PDF, 然后通过简单的方法调用应用所需的旋转或方向。 快速保存更新的文档, 确保布局符合任何特定要求。 此快速指南帮助您轻松开始。 Get started making PDFs with NuGet now: Install IronPDF with NuGet Package Manager PM > Install-Package IronPdf Copy and run this code snippet. IronPdf.PdfDocument.FromFile("file.pdf") .SetAllPageRotations(IronPdf.PdfDocument.PageRotation.Rotate90) .SaveAs("rotated.pdf"); Deploy to test on your live environment Start using IronPDF in your project today with a free trial Free 30 day Trial class="hsg-featured-snippet"> 最少工作流程(5步) 下载用于PDF页面方向和旋转的IronPDF C#库 在渲染之前使用PaperOrientation属性设置页面方向 探索IronPDF的所有页面旋转选项 学习旋转单个或多个PDF页面的方法 使用IronPDF检索PDF页面旋转 页面方向示例 只有在从其他格式生成PDF文档时才能设置方向。 您可以从RenderingOptions类中访问PaperOrientation属性。 此属性可以设置为纵向或横向。 纵向是默认的页面方向设置。 代码 :path=/static-assets/pdf/content-code-examples/how-to/page-orientation-rotation-orientation.cs using IronPdf; using IronPdf.Rendering; ChromePdfRenderer renderer = new ChromePdfRenderer(); // Change paper orientation renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape; PdfDocument pdf = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page"); pdf.SaveAs("landscape.pdf"); Imports IronPdf Imports IronPdf.Rendering Private renderer As New ChromePdfRenderer() ' Change paper orientation renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape Dim pdf As PdfDocument = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page") pdf.SaveAs("landscape.pdf") $vbLabelText $csharpLabel 输出 PDF 文件 <hr 页面旋转示例 IronPDF提供了四个可能的旋转度数: None: 0度或未旋转的文档。 Clockwise90: 顺时针旋转90度。 Clockwise180: 顺时针旋转180度。 Clockwise270: 顺时针旋转270度。 请注意所有以下页面索引位置均采用零基索引。 设置页面旋转 使用以下方法设置单个页面, 多个页面或所有页面的旋转。 SetAllPageRotations: 设置所有页面的旋转度数。 SetPageRotation: 设置单个页面的旋转度数。 SetPageRotations: 设置选定页面列表的旋转度数。 :path=/static-assets/pdf/content-code-examples/how-to/page-orientation-rotation-set-rotation.cs using IronPdf; using IronPdf.Rendering; using System.Collections.Generic; PdfDocument pdf = PdfDocument.FromFile("landscape.pdf"); // Set all pages pdf.SetAllPageRotations(PdfPageRotation.Clockwise90); // Set a single page pdf.SetPageRotation(1, PdfPageRotation.Clockwise180); // Set multiple pages List<int> selectedPages = new List<int>() { 0, 3 }; pdf.SetPageRotations(selectedPages, PdfPageRotation.Clockwise270); pdf.SaveAs("rotatedLandscape.pdf"); Imports IronPdf Imports IronPdf.Rendering Imports System.Collections.Generic Private pdf As PdfDocument = PdfDocument.FromFile("landscape.pdf") ' Set all pages pdf.SetAllPageRotations(PdfPageRotation.Clockwise90) ' Set a single page pdf.SetPageRotation(1, PdfPageRotation.Clockwise180) ' Set multiple pages Dim selectedPages As New List(Of Integer)() From {0, 3} pdf.SetPageRotations(selectedPages, PdfPageRotation.Clockwise270) pdf.SaveAs("rotatedLandscape.pdf") $vbLabelText $csharpLabel 输出 PDF 文件 获取页面旋转 使用GetPageRotation方法检索PDF文档中特定页面的旋转。 只需将页面索引提供给方法。 :path=/static-assets/pdf/content-code-examples/how-to/page-orientation-rotation-get-rotation.cs using IronPdf; using IronPdf.Rendering; PdfDocument pdf = PdfDocument.FromFile("rotatedLandscape.pdf"); PdfPageRotation rotation = pdf.GetPageRotation(1); Imports IronPdf Imports IronPdf.Rendering Private pdf As PdfDocument = PdfDocument.FromFile("rotatedLandscape.pdf") Private rotation As PdfPageRotation = pdf.GetPageRotation(1) $vbLabelText $csharpLabel 常见问题解答 如何使用C#在PDF中设置页面方向? 您可以使用IronPDF中的RenderingOptions类的PaperOrientation属性设置页面方向。此属性可以在渲染PDF之前设置为纵向或横向。 PDF页面的可能旋转角度是什么? IronPDF允许您将PDF页面旋转到四个可能的角度:0度(无)、90度(顺时针90)、180度(顺时针180)和270度(顺时针270)。 如何使用C#旋转PDF文档中的所有页面? 您可以使用IronPDF的SetAllPageRotations方法旋转PDF文档中的所有页面,指定所需的旋转角度(例如,PdfPageRotation.Clockwise90)。 是否可以使用C#旋转PDF中的特定页面? 是的,您可以使用IronPDF的SetPageRotation方法旋转单个页面,或使用SetPageRotations为多个页面提供索引来旋转特定页面。 如何确定PDF页面的当前旋转? 您可以使用IronPDF中的GetPageRotation方法,通过提供页面索引来检索特定页面的旋转角度。 创建新PDF时的默认页面方向是什么? 使用IronPDF创建新PDF时的默认页面方向是纵向。 我是否需要任何其他库来操控PDF中的页面方向和旋转? 是的,您需要下载IronPDF C#库来操控PDF中的页面方向和旋转。 使用IronPDF进行PDF操作的好处是什么? IronPDF为在C#中创建、编辑和操控PDF文档提供了全面的工具集,包括设置页面方向和旋转,这提高了文档的展示效果并符合特定的查看偏好。 IronPDF 是否完全兼容 .NET 10,包括方向和旋转功能? 是的——IronPDF 支持 .NET 10 以及早期版本(.NET 9、8 等),并且可以与所有页面方向和旋转功能(如RenderingOptions.PaperOrientation 、 SetPageRotation 、 SetAllPageRotations和GetPageRotation )无缝配合使用。 Chaknith Bin 立即与工程团队聊天 软件工程师 Chaknith 在 IronXL 和 IronBarcode 工作。他在 C# 和 .NET 方面有着深厚的专业知识,帮助改进软件并支持客户。他从用户互动中获得的见解有助于更好的产品、文档和整体体验。 准备开始了吗? Nuget 下载 16,154,058 | 版本: 2025.11 刚刚发布 免费 NuGet 下载 总下载量:16,154,058 查看许可证