PdfDocument Class

Represents a new PDF document being constructed in memory

Definition

Namespace: HiQPdf.Next
Assembly: HiQPdf.Next (in HiQPdf.Next.dll) Version: 18.9.2
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

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 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
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
PdfStandard PDF standard targeted by this document. Set through PdfDocumentCreateSettings.PdfStandard at construction time
Properties Controls the title, subject, keywords, author and the creation date of the PDF document
Security The object exposed by this property can be used to password protect the PDF document, disable printing, copying or editing of the PDF document
Viewer Controls the PDF viewer preferences

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
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 added to the Attachments panel alongside any other attachments
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 height of template is fixed. If AutoResizeHeight is true, the HTML content may be scaled down to fit the specified 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, 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, 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 fixed. If AutoResizeHeight is true, the HTML content may be scaled down to fit the specified 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) 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 height of template is fixed. If AutoResizeHeight is true, the HTML content may be scaled down to fit the specified height
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 height of template is fixed. If AutoResizeHeight is true, the HTML content may be scaled down to fit the specified height.
AddImage Adds an image element to the current PDF page. Supports byte array or file path images, scaling and alignment
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 target an external URL, another page in the same document, a specific location on another page, or a named destination defined in the document catalog. Use one of the static factory methods on PdfLinkAnnotation (FromUrl, ToPage, ToPageLocation, ToNamedDestination) to build the link
AddPage Adds a new page to the PDF document using the current PDF page size. Use PageSize property or SetPageSize method to set the current PDF page size
AddPath Adds a generic path composed of move, line and curve operations to the current PDF page
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
AddText Adds a text element to the current PDF page. If the text exceeds the current page, it can continue on subsequent pages depending on the value of the ContinueOnNextPage property. Supports placeholder variables such as {page_number} and {total_pages}, which are replaced with their actual values in the rendered PDF. When {total_pages} is used, the text element is rendered after the document is closed. Therefore, the PdfDocument instance cannot be used inside the OnPageRendered callback.
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 Finalizes and returns the PDF document as a byte array
SaveAsync Asynchronously finalizes and returns the PDF document as a byte array
SaveToFile Saves the PDF document to the specified file
SaveToFileAsync Asynchronously saves the PDF document to the specified file
SetPageSize Gets the page size of the PDF document used when creating new PDF pages
ToString
(Inherited from Object)

See Also