Editing a PDF's individual pages

Explanation

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:

Transition

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.

Alignment

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.

Display

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:

Conclusion