Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
PdfPageEditor class is different from PdfFileEditor and PdfContentEditor class. First we need to understand the difference, and then we’ll be able to better understand the PdfPageEditor class. PdfFileEditor class allows you manipulate all the pages in a file like adding, deleting, or concatenating pages etc, while PdfContentEditor class helps you manipulate the contents of a page i.e. text and other objects etc. Whereas, PdfPageEditor class only works with the individual page itself like rotating, zooming, and aligning a page etc.
We can divide the features provided by this class into three main categories i.e. Transition, Alignment, and Display. We’re going to discuss these categories below:
This class contains two properties related to transition i.e. TransitionType and TransitionDuration. TransitionType specifies the transition style to be used when moving to this page from another page during a presentation. TransitionDuration specifies display duration for the pages.
PdfPageEditor class supports both horizontal and vertical alignments. It provides two properties to serve the purpose i.e. Alignment and VerticalAlignment. Alignment property is used to align the contents horizontally. Alignment property takes a value of AlignmentType, which contains three options i.e. Center, Left, and Right. VerticalAlignment property takes a value of VerticalAlignmentType, which contains three options i.e. Bottom, Center, and Top.
Under display category we can include properties like PageSize, Rotation, Zoom, and DisplayDuration. PageSize property specifies the size of individual page in the file. This property takes PageSize object as an input, which encapsulates predefined page size like A0, A1, A2, A3, A4, A5, A6, B5, Letter, Ledger, and P11x17. Rotation property is used to set the rotation of an individual page. It can take values 0, 90, 180, or 270. Zoom property sets the zoom coefficient for the page, and it takes a float value as an input. This class also provides method to get page size and page rotation of the individual page in the file.
You can find samples of the above mentioned methods in the code snippet given below:
// 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.