PdfDocument Class

Represents a new PDF document being constructed in memory

Definition

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

Constructors

PdfDocument Initializes a new instance of the PdfDocument class with default settings. To explicitly set the PDF page size, orientation, or margins, use the constructor that accepts a PdfDocumentCreateSettings object
PdfDocument(PdfDocumentCreateSettings) Initializes a new instance of the PdfDocument class using the specified creation settings.

Properties

Bookmarks The outline of the document, displayed as bookmarks in the navigation panel of PDF viewers. The bookmarks open pages of the document or web addresses and can be nested. The location in a page is relative to the content area inside the margins, like the other positions in the document
ContentHeight Gets the available content height of the current PDF page, after applying the top and bottom margins
ContentWidth Gets the available content width of the current PDF page, after applying the left and right margins
DigitalSignature The digital signature to apply to generated PDF document
Flatten A flag indicating if the resulted PDF is flattened: the form fields are drawn as static page content instead of interactive fields. The default value is false
Margins Gets a copy of the current PDF document margins or sets the new margins used when adding new PDF elements to document
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. Set it to null to open the document on the first page. The default is null
PageNumber Gets the current page number in the PDF document (1-based index)
PageSize Gets the page size of the PDF document used when creating new PDF pages
PdfDocumentInfo Gets a reference to the object to controlling the generated PDF document information like the document title, author, subject or creation date
PdfSecurityOptions Gets a reference to the object to controlling the generated PDF document security settings like user and owner password, restrict printing or editing of the generated PDF document
PdfStandard PDF standard targeted by this document. Set through PdfDocumentCreateSettings.PdfStandard at construction time
PdfViewerPreferences Gets a reference to the object controlling how the generated PDF is displayed by a PDF viewer
TableOfContents The table of contents of the document, generated when the document is saved from the headings of the HTML content added to it. The table is disabled by default

Methods

AddArc Adds an elliptical arc to the current PDF page
AddCircle Adds a circle defined by center and radius to the current PDF page
AddElectronicInvoice Embeds a Factur-X / ZUGFeRD electronic invoice in the 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 written in the XMP metadata. The document must be created as PDF/A-3 (PdfA3b, PdfA3u, PdfA3a or PdfUa1PdfA3a for an accessible invoice). A document carries one electronic invoice
AddEllipse Adds an ellipse inscribed in a bounding rectangle to the current PDF page
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
AddHtml Renders HTML content in the document: the content starts at the position given by the element in the current page and continues on as many new pages as it needs, inside the margins of the document. The links, the form fields and, when the document is tagged, the structure 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 document: the content starts at the position given by the element in the current page and continues on as many new pages as it needs, inside the margins of the document. The links, the form fields and, when the document is tagged, the structure 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 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 in the current page. When the ContinueOnNextPage property of the element is true, the default, an image taller than the space left on the page continues on new pages, inside the margins of the document, and the current page becomes the last page of the image. The elements added after this call go to that page, below LastPageRectangle
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 the current PDF page. Supports byte array or file path images, scaling and alignment. When the ContinueOnNextPage property of the element is true, an image taller than the space left on the page continues on new pages, inside the margins of the document, and the current page becomes the last page of the image
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
AddLine Adds a straight line between two points to the current PDF page
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
AddPage Adds a new page to the document. The page has the given size and orientation, which become the current ones for the pages added next, or the current page size when no size is given
AddPath Adds a generic path composed of move, line and curve operations to the current PDF page
AddPdfPage Draws a page of an existing PDF document in the current page, 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 the document is tagged and the drawn page comes from a document tagged for the same standard. The links between the pages drawn from the same document data or file lead to the drawn pages
AddPdfTemplate Creates a PDF template object with the specified position and size in the PDF page. Static content added to this template is rendered on the current page immediately. Dynamic text containing {page_number} or {total_pages} is rendered when the document is saved
AddPolygon Adds a closed polygon through a sequence of vertices to the current PDF page
AddPolyline Adds an open polyline through a sequence of points to the current PDF page
AddRectangle Adds a rectangle shape to the current page
AddRoundedRectangle Adds a rectangle with rounded corners to the current PDF page
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 the current PDF page. When the ContinueOnNextPage property of the element is true, the text that does not fit on the current page continues on the next pages of the document. The text can contain the {page_number} and {total_pages} placeholders, replaced with the page number and the page count of the document. A text with placeholders is rendered on the current page only, even when it continues on the next pages. A text with {total_pages} is rendered when the document is saved: the returned object has no rendered rectangles and the page callbacks of the element are called at save time, when the document cannot be changed anymore
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
Equals
(Inherited from Object)
Finalize
(Inherited from Object)
GetHashCode
(Inherited from Object)
GetType
(Inherited from Object)
MemberwiseClone
(Inherited from Object)
Save Saves the PDF document to a byte array and releases all resources; the document cannot be used afterwards
SaveAsync Asynchronously saves the PDF document to a byte array and releases all resources; the document cannot be used afterwards
SaveToFile Saves the PDF document to the specified file
SaveToFileAsync Asynchronously saves the PDF document to the specified file
SetPageSize Sets the page size and the orientation of the pages added next
ToString
(Inherited from Object)

Extension Methods

AddExcel Renders an Excel workbook in the PDF document: the content starts at the position given by the element in the current page and continues on as many new pages as it needs, inside the margins of the PDF document. The content keeps the formatting, the images and the shapes of the worksheets, and each worksheet can start on a new page. The elements added after this call go to the last page of the content, below LastPageRectangle
(Defined by ExcelPdfDocumentExtensions)
AddExcelAsync Asynchronously renders an Excel workbook in the PDF document: the content starts at the position given by the element in the current page and continues on as many new pages as it needs, inside the margins of the PDF document. The content keeps the formatting, the images and the shapes of the worksheets, and each worksheet can start on a new page. The elements added after this call go to the last page of the content, below LastPageRectangle
(Defined by ExcelPdfDocumentExtensions)
AddMarkdown Renders a Markdown document in the PDF document: the content starts at the position given by the element in the current page and continues on as many new pages as it needs, inside the margins of the PDF document. The content keeps its structure, headings, links, code blocks and images, and its headings can join the outline of the PDF document. The elements added after this call go to the last page of the content, below LastPageRectangle
(Defined by MarkdownPdfDocumentExtensions)
AddMarkdownAsync Asynchronously renders a Markdown document in the PDF document: the content starts at the position given by the element in the current page and continues on as many new pages as it needs, inside the margins of the PDF document. The content keeps its structure, headings, links, code blocks and images, and its headings can join the outline of the PDF document. The elements added after this call go to the last page of the content, below LastPageRectangle
(Defined by MarkdownPdfDocumentExtensions)
AddRtf Renders an RTF document in the PDF document: the content starts at the position given by the element in the current page and continues on as many new pages as it needs, inside the margins of the PDF document. The content keeps its formatting, headings, links and images, and its headings can join the outline of the PDF document. The elements added after this call go to the last page of the content, below LastPageRectangle
(Defined by RtfPdfDocumentExtensions)
AddRtfAsync Asynchronously renders an RTF document in the PDF document: the content starts at the position given by the element in the current page and continues on as many new pages as it needs, inside the margins of the PDF document. The content keeps its formatting, headings, links and images, and its headings can join the outline of the PDF document. The elements added after this call go to the last page of the content, below LastPageRectangle
(Defined by RtfPdfDocumentExtensions)
AddWord Renders a Word document in the PDF document: the content starts at the position given by the element in the current page and continues on as many new pages as it needs, inside the margins of the PDF document. The content keeps its structure, headings, links and images, and its headings can join the outline of the PDF document. The elements added after this call go to the last page of the content, below LastPageRectangle
(Defined by WordPdfDocumentExtensions)
AddWordAsync Asynchronously renders a Word document in the PDF document: the content starts at the position given by the element in the current page and continues on as many new pages as it needs, inside the margins of the PDF document. The content keeps its structure, headings, links and images, and its headings can join the outline of the PDF document. The elements added after this call go to the last page of the content, below LastPageRectangle
(Defined by WordPdfDocumentExtensions)

See Also