PdfEditor Class

Allows editing of existing PDF documents by adding HTML content, text, images and shapes, form fields and annotations, filling the existing form fields, inserting, moving and rotating pages, setting metadata, security options and digital signatures. Positions in a page are measured in points from the top left corner of the page as it is displayed, so a rotated page is edited the way it is seen. Use Save or SaveToFile(String) to generate the final PDF and release resources. A password protected document is opened with its password and saved without protection, unless new security options are set. A document that already carries digital signatures accepts a new digital signature, long-term validation data and form field values, saved as incremental updates that keep the existing signatures valid, and refuses any other change

Definition

Namespace: Winnovative.Pdf.Next
Assembly: Winnovative.Pdf.Next (in Winnovative.Pdf.Next.dll) Version: 21.0.3
C#
public class PdfEditor : IDisposable
Inheritance
Object    PdfEditor
Implements
IDisposable

Constructors

PdfEditor(Byte, String) Creates an editor for a PDF from a memory buffer
PdfEditor(String, String) Creates an editor for a PDF from a file
PdfEditor(Byte, String, PdfDigitalSignature) Creates an editor for a PDF loaded from a memory buffer, with a digital signature to be applied when the PDF is saved
PdfEditor(String, String, PdfDigitalSignature) Creates an editor for a PDF loaded from a file, with a digital signature to be applied when the PDF is saved

Properties

Bookmarks The outline of the document, displayed as bookmarks in the navigation panel of PDF viewers. The collection holds the bookmarks of the loaded document, which can be changed, removed or reordered, and the bookmarks added to it. The outline is written when the document is saved. The location in a page is given from the top left corner of the page. The outline of a signed document can be read but not changed
ContainsEmbeddedFiles Indicates whether the loaded PDF contains embedded files
ContainsForm Indicates whether the loaded PDF contains an interactive form
ContainsJavaScript Indicates whether the loaded PDF contains JavaScript code
DigitalSignature The digital signature applied to the document when it is saved, given to the constructor or set before the save. When null, the default of the constructors without a signature, the document is saved without a new signature
DocumentInfo The metadata (title, author, etc.) read from the loaded document
Flatten A flag indicating if the output PDF is flattened: the form fields become static page content and the form is removed from the document. The default value is false
Form The interactive form of the loaded document, used to read and fill its fields. The changes are written when the document is saved. The fields of a signed document can be filled too, unless the document is certified without changes allowed, while no other content can be added to a signed document
IsLinearized Indicates whether the loaded PDF is linearized (Fast Web View). Linearized PDFs are optimized for rendering the first page before the entire file is downloaded
IsSigned Indicates whether the loaded PDF document contains at least one digital signature. This property checks for the presence of signature dictionaries. It does NOT validate the signatures cryptographically
IsTaggedPdf Indicates whether the loaded PDF is a tagged PDF
OpenAction The action executed by the viewer when the document is opened: go to a page at a given location and zoom, go to a named destination, run JavaScript, a viewer action or open a web address. It holds the open action of the loaded document when it has one of these types. Set it to null to open the document on the first page
PageCount The number of pages of the document
PdfDocumentInfo The metadata (title, author, etc.) of the saved document; the values read from the loaded document are kept when they are not set
PdfSecurityOptions The security options (passwords, permissions) of the saved document
PdfVersion Gets the PDF specification version of the loaded document (for example "1.4", "1.7", "2.0")
PdfViewerPreferences The viewer preferences of the saved document
SecurityInfo The security information (permissions, encryption) read from the loaded document
SignatureInfo The digital signatures of the loaded document: their count, the certification and its level
ViewerPreferencesInfo The viewer preferences read from the loaded document

Methods

AddArc Adds an elliptical arc to a specified page in the existing PDF document
AddCircle Adds a circle to a specified page in the existing PDF document
AddElectronicInvoice Embeds a Factur-X / ZUGFeRD electronic invoice in the edited PDF document: the invoice XML is attached under the file name the standard prescribes, with the relationship of its profile, and the Factur-X identification metadata is added to the XMP metadata of the document. The edited document must be a PDF/A-3 document. A document carries one electronic invoice
AddEllipse Adds an ellipse to a specified page in the existing PDF document
AddFileAttachment Adds a file to the document's attachments. The attachment appears in the Attachments panel of PDF viewers but has no visible icon on any page. To also display a clickable icon on a specific page, use AddFileAttachmentAnnotation(PdfFileAttachmentAnnotation)
AddFileAttachmentAnnotation Adds a file attachment displayed as a clickable icon on a specific page. Clicking the icon opens or extracts the attached file. The file is also listed in the Attachments panel when the AddToAttachmentsPanel property of the annotation is true
AddFormField Adds an interactive form field to a page of the document: a text field, check box, radio button group, combo box, list box or push button. The field name must be unique in the document. When Flatten is true the field is drawn as static content instead. The fields the document already has are read and filled with Form
AddHtml Renders HTML content in the pages of the document: the content starts at the position given by the element in a page, relative to the top left corner of the page, and continues on the following pages of the document, or on pages inserted after the given page when InsertContinuationPages is true, between the ContinuationTopMargin and ContinuationBottomMargin margins of the pages. The pages where the content continues have the size of the page where it starts. The links and the form fields of the rendered content are kept and the outline generated from the HTML headings, when the converter is set to generate one, is added to the bookmarks of the document. The elements added after this call go to the last page of the content, below LastPageRectangle
AddHtmlAsync Asynchronously renders HTML content in the pages of the document: the content starts at the position given by the element in a page, relative to the top left corner of the page, and continues on the following pages of the document, or on pages inserted after the given page when InsertContinuationPages is true, between the ContinuationTopMargin and ContinuationBottomMargin margins of the pages. The pages where the content continues have the size of the page where it starts. The links and the form fields of the rendered content are kept and the outline generated from the HTML headings, when the converter is set to generate one, is added to the bookmarks of the document. The elements added after this call go to the last page of the content, below LastPageRectangle
AddHtmlImage Renders HTML content as an image in a page of the document: the HTML is converted to an image with the converter of the element and the image is drawn from the position given by the element, relative to the top left corner of the page. When the ContinueOnNextPage property of the element is true, the default, an image taller than the space left on the page continues on the following pages of the document, or on pages inserted after the given page when InsertContinuationPages is true, between the ContinuationTopMargin and ContinuationBottomMargin margins of the pages
AddHtmlTemplate(Int32, Int32, Int32, String) Creates a HTML Template object based on the HTML string and an optional base URL. The height of template is auto-resized. To create a template with fixed height use the method with height parameter
AddHtmlTemplate(Int32, Int32, Int32, Int32, String) Creates a HTML Template object based on URL from which the HTML content should be retrieved. The template has the given height. When AutoSizeContentHeight is true, the HTML content may be scaled down to fit the given height
AddHtmlTemplate(Int32, Int32, Int32, String, String) Creates a HTML Template object to be rendered in PDF pages based on the HTML string and an optional base URL. The height of template is auto-resized. To create a template with fixed height use the method with height parameter
AddHtmlTemplate(Int32, Int32, Int32, Int32, String, String) Creates a HTML Template object to be rendered in PDF pages based on the HTML string and an optional base URL. The template has the given height. When AutoSizeContentHeight is true, the HTML content may be scaled down to fit the given height
AddHtmlTemplate(Int32, Int32, Int32, PdfTemplateHorizontalAlign, PdfTemplateVerticalAlign, String) Creates a HTML Template object based on the HTML string and an optional base URL. Specifies the horizontal and the vertical alignment of the template on the PDF page. The alignment takes precedence over the X and Y coordinates when set to a value other than None. The height of template is auto-resized. To create a template with fixed height use the method with height parameter
AddHtmlTemplate(Int32, Int32, Int32, Int32, PdfTemplateHorizontalAlign, PdfTemplateVerticalAlign, String) Creates a HTML Template object based on URL from which the HTML content should be retrieved. Specifies the horizontal and the vertical alignment of the template on the PDF page. The alignment takes precedence over the X and Y coordinates when set to a value other than None. The template has the given height. When AutoSizeContentHeight is true, the HTML content may be scaled down to fit the given height
AddHtmlTemplate(Int32, Int32, Int32, PdfTemplateHorizontalAlign, PdfTemplateVerticalAlign, String, String) Creates a HTML Template object to be rendered in PDF pages based on the HTML string and an optional base URL. Specifies the horizontal and the vertical alignment of the template on the PDF page. The alignment takes precedence over the X and Y coordinates when set to a value other than None. The height of template is auto-resized. To create a template with fixed height use the method with height parameter
AddHtmlTemplate(Int32, Int32, Int32, Int32, PdfTemplateHorizontalAlign, PdfTemplateVerticalAlign, String, String) Creates a HTML Template object to be rendered in PDF pages based on the HTML string and an optional base URL. Specifies the horizontal and the vertical alignment of the template on the PDF page. The alignment takes precedence over the X and Y coordinates when set to a value other than None. The template has the given height. When AutoSizeContentHeight is true, the HTML content may be scaled down to fit the given height
AddImage Adds an image element to a page of the document, at the position given by the element relative to the top left corner of the page. When the ContinueOnNextPage property of the element is true, an image taller than the space left on the page continues on the following pages of the document, or on pages inserted after the given page when InsertContinuationPages is true, between the ContinuationTopMargin and ContinuationBottomMargin margins of the pages
AddJavaScript Adds JavaScript code that runs when the document is opened in a PDF viewer. The functions defined by the code can be called from the actions of the form fields. The scripts the document already has are kept
AddLine Adds a line to a specified page in the existing PDF document
AddLinkAnnotation Adds a clickable hyperlink annotation placed on a specific page. The link can open an external URL, go to another page of the document or to a location on another page. Use one of the static factory methods of PdfLinkAnnotation (FromUrl, ToPage, ToPageLocation) to build the link
AddLongTermValidation Adds the validation data of the signatures when the document is saved: the certificates and their revocation information, so the signatures can be validated after the certificates expire. Signatures that carry a signature timestamp reach the PAdES B-LT level or, when a timestamp server is set and a document timestamp is added over the validation data, the PAdES B-LTA level. The document timestamp also renews the protection of the signatures that already have one
AddPage Adds a new blank page at the end of the document. The new page inherits the size of the last existing page
AddPage(PdfPageSize, PdfPageOrientation) Adds a new blank page of the given size at the end of the document
AddPath Adds a generic path composed of move, line and curve operations to a specified page in the existing PDF document
AddPdfPage Draws a page of another PDF document in a page of the edited document, at the position and with the size, rotation and opacity given by the element. The links and the form fields of the drawn page are kept, and its structure is kept when both documents are tagged. The links between the pages drawn from the same document data or file lead to the drawn pages. The position is relative to the top left corner of the page
AddPdfTemplate Creates a blank PDF Template object with the specified position and size in the PDF page. Specifies the horizontal and vertical alignment of the template on the page. The alignment takes precedence over the X and Y coordinates when set to a value other than None. The template can later be filled with custom content such as text, images or graphics
AddPolygon Adds a closed polygon through a sequence of vertices to a specified page in the existing PDF document
AddPolyline Adds an open polyline through a sequence of points to a specified page in the existing PDF document
AddRectangle Adds a rectangle to a specified page in the existing PDF document
AddRoundedRectangle Adds a rectangle with rounded corners to a specified page in the existing PDF document
AddSignatureField Adds an empty signature field to a page of the document. The field is signed later by a digital signature with the same field name, which is placed on the field's page and in its rectangle. A form with a field for each signer is prepared this way. The field name must be unique in the document
AddText Adds a text element to a page of the document, at the position given by the element relative to the top left corner of the page. When the ContinueOnNextPage property of the element is true, the text that does not fit on the page continues on the following pages of the document, or on pages inserted after the given page when InsertContinuationPages is true, between the ContinuationTopMargin and ContinuationBottomMargin margins of the pages. The text can contain the {page_number} and {total_pages} placeholders, replaced with the number of the given page and the page count of the document; a text with placeholders is rendered on the given page only
AddTextAnnotation Adds a sticky-note text annotation displayed as a clickable icon on a specific page. Clicking the icon opens a popup with the note text. The annotation also appears in the viewer's Comments panel
Dispose Releases all resources used by this instance
Dispose(Boolean) Performs the actual resource cleanup
Equals
(Inherited from Object)
Finalize
(Inherited from Object)
GetHashCode
(Inherited from Object)
GetPdfPageInfo Gets detailed information about a specific page in the loaded PDF document.
GetType
(Inherited from Object)
InsertPage Inserts a new blank page before the page with the given number. The pages from that number on are shifted by one. The new page has the given size, or the size of the page it is inserted before when no size is given. The content, the links and the bookmarks of the existing pages are not changed; the bookmarks and the open action set in the editor keep pointing to the same pages
MemberwiseClone
(Inherited from Object)
MovePage Moves a page to another position in the document. The other pages keep their order. The content, the links and the bookmarks of the pages are not changed; the bookmarks and the open action set in the editor keep pointing to the same pages
RemovePage Removes a page from the document. The pages after it are shifted by one. The bookmarks and the links that led to the removed page lose their destination; the bookmarks and the open action set in the editor keep pointing to the same pages
RemovePages Removes pages from the document. The remaining pages are renumbered. The bookmarks and the links that led to the removed pages lose their destination; the bookmarks and the open action set in the editor keep pointing to the same pages
RotatePage Rotates a page by a multiple of 90 degrees, clockwise for a positive angle. The rotation is added to the current rotation of the page. The page is rotated before content is added to it in the editor
Save Saves the edited PDF to a memory buffer and releases all resources
SaveAsync Asynchronously saves the edited PDF to a memory buffer and releases all resources
SaveToFile Saves the edited PDF to a file and releases all resources
SaveToFileAsync Asynchronously saves the edited PDF to a file and releases all resources
SetPageRotation Sets the rotation of a page: 0, 90, 180 or 270 degrees clockwise. The page is rotated before content is added to it in the editor
ToString
(Inherited from Object)

See Also