Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
PdfPageEditor 类与 PdfFileEditor 和 PdfContentEditor 类不同。首先,我们需要了解它们之间的区别,然后我们才能更好地理解 PdfPageEditor 类。PdfFileEditor 类允许您操作文件中的所有页面,例如添加、删除或连接页面等,而 PdfContentEditor 类帮助您操作页面的内容,即文本和其他对象等。而 PdfPageEditor 类仅处理单独页面本身,例如旋转、缩放和对齐页面等。
我们可以将此类提供的功能分为三个主要类别,即过渡、对齐和显示。我们将在下面讨论这些类别:
此类包含两个与过渡相关的属性,即 TransitionType 和 TransitionDuration。TransitionType 指定在演示期间从另一页面移动到此页面时使用的过渡样式。TransitionDuration 指定页面的显示持续时间。
PdfPageEditor 类支持水平和垂直对齐。它提供两个属性来实现此目的,即 Alignment 和 VerticalAlignment。Alignment 属性用于水平对齐内容。Alignment 属性接受 AlignmentType 的值,其中包含三个选项:居中、左对齐和右对齐。VerticalAlignment 属性接受 VerticalAlignmentType 的值,其中包含三个选项:底部、居中和顶部。
在显示类别下,我们可以包括 PageSize、Rotation、Zoom 和 DisplayDuration 等属性。PageSize 属性指定文件中单独页面的大小。此属性接受 PageSize 对象作为输入,该对象封装了预定义的页面大小,如 A0、A1、A2、A3、A4、A5、A6、B5、Letter、Ledger 和 P11x17。Rotation 属性用于设置单独页面的旋转。它可以接受 0、90、180 或 270 的值。Zoom 属性设置页面的缩放系数,并接受浮点值作为输入。此类还提供方法以获取文件中单独页面的页面大小和页面旋转。
您可以在下面给出的代码片段中找到上述方法的示例:
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void EditPdfPages()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Create a new instance of PdfPageEditor class
using (var pdfPageEditor = new Aspose.Pdf.Facades.PdfPageEditor())
{
// Bind PDF document
pdfPageEditor.BindPdf(dataDir + "FilledForm.pdf");
// Specify an array of pages which need to be manipulated (pages can be multiple, here we have specified only one page)
pdfPageEditor.ProcessPages = new int[] { 1 };
// Alignment related code
pdfPageEditor.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Right;
// Specify transition type for the pages
pdfPageEditor.TransitionType = 2;
// Specify transition duration
pdfPageEditor.TransitionDuration = 5;
// Display related code
// Select a page size from the enumeration and assign to property
pdfPageEditor.PageSize = Aspose.Pdf.PageSize.PageLedger;
// Assign page rotation
pdfPageEditor.Rotation = 90;
// Specify zoom factor for the page
pdfPageEditor.Zoom = 100;
// Assign display duration for the page
pdfPageEditor.DisplayDuration = 5;
// Fetching methods
// Methods provided by the class, page rotation specified already
var rotation = pdfPageEditor.GetPageRotation(1);
// Already specified page can be fetched
var pageSize = pdfPageEditor.GetPageSize(1);
// This method gets the page count
var totalPages = pdfPageEditor.GetPages();
// This method changes the origin from (0,0) to specified number
pdfPageEditor.MovePosition(100, 100);
// Save PDF document
pdfPageEditor.Save(dataDir + "EditPdfPages_out.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.