PdfHtmlTemplate Class

A PDF Template can be used to repeat HTML content on multiple PDF pages. The HTML content can contain placeholders such as {page-number} and {total-pages} to be replaced when generating the final PDF.

Definition

Namespace: HiQPdf.Chromium
Assembly: HiQPdf.Chromium (in HiQPdf.Chromium.dll) Version: 17.0.0
C#
public class PdfHtmlTemplate
Inheritance
Object    PdfHtmlTemplate
Derived

Properties

AllowInsecureContent Allows loading insecure HTTP content in secure HTTPS pages. The default value is false
AutoSizeContentHeight Allows the PDF template content height to be auto resized based on the rendered HTML content height. The minimum and maximum heights are controlled by the MinContentHeight and MaxContentHeight properties. When this property is false, the content height is given by the Height property. When this property is true, if the Height property is set with a positive value and the FitHeight property is also true, the content may be scaled down to fit the specified height. The default value is true
CountEndPages Specifies whether the external PDF pages inserted after the HTML to PDF conversion result are included in the total page count used for page numbering. Is ignored if ShowOnlyInHtmlToPdfPages is explicitly set to false. The default value is true
CountStartPages Specifies whether the external PDF pages inserted before the HTML to PDF conversion result are included in the total page count used for page numbering. Is ignored if ShowOnlyInHtmlToPdfPages is explicitly set to false. The default value is true
CountTocPages In HTML to PDF conversion, determines whether the Table of Contents (TOC) pages inserted before the conversion result are included in the total page count used for page numbering. This setting has no effect for inline TOCs. It is ignored if ShowOnlyInHtmlToPdfPages is explicitly set to false. The default value is true
DestinationSize The template destination size in PDF page determined during rendering
DisableSiteIsolation Disables site isolation when loading content from different sources. The default value is false
DisableWebSecurity Disables web security features such as CORS and same-origin policy. The default value is false
FitHeight If true, when AutoSizeContentHeight is also true and Height was set with a positive value, the HTML content may be scaled down to fit the template height in PDF. The default value is true
GpuCompositingEnabled Controls if the GPU compositing is enabled in the HTML to PDF converter. It should be enabled to convert web page with WebGL. The default value is false
GpuRenderingEnabled Controls if the GPU rendering is enabled in the HTML to PDF converter. The default value is false
Height Gets or sets the height of the PDF template. It is used together with AutoSizeContentHeight property to determine the destination height of the template in PDF page. When it is set with a positive value, it gives the template height if AutoSizeContentHeight is false or if AutoSizeContentHeight is true and FitHeight is also true. When it is set to a 0 or a negative value and the AutoSizeContentHeight is true, the PDF template height is auto determined based on the HTML content height. The default value is 0
HorizontalAlign Specifies the horizontal alignment of the template on the PDF page. Takes precedence over the X coordinate when set to a value other than None. This property is ignored for header and footer templates. The default value is None
Html Gets or sets the HTML content of the template. It can contain template variable like {page_number} or {total_pages}
HtmlBaseUrl Gets or sets the base URL used to resolve external resources in the HTML
HtmlLoaderFilePath Sets the full path of HTML loader file used for HTML templates rendering
HtmlSourceUrl Gets or sets the URL from which the HTML content should be retrieved. The HTML content can contain template variable like {page_number} or {total_pages}. The Html property takes precedence if both are set
IgnoreCertificateErrors Ignores certificate validation errors such as expired, self-signed or invalid certificates. The default value is false
Margins The margins to be applied to HTML template. The default margins are 0
MaxContentHeight Gets or sets the maximum height of the PDF template. This property is used when AutoSizeContentHeight is true to limit the height of the HTML content. The default value is 24000
MinContentHeight Gets or sets the minimum height of the PDF template. This property is used when AutoSizeContentHeight is true to limit the height of the HTML content. The defaul value is 0
Opacity The opacity as a value between 0 and 1 to be applied to entire template. For example, setting this property to 0.75 will lower the opacity to 75% . The default value is 1 and the rendered PDF content will have its original opacity. If you want to control only the opacity of the HTML template background, you can do this by setting the body element style to background-color: rgba(255, 255, 255, 0.75), which will set the opacity to 0.75
PageCounterAutoSize A flag indicating if the converter will automatically set the page counter width.
PageCounterFontScale A zoom factor applied to the font used to display the {page_number} and {total_pages} placeholders. It must be a value between 0.1 and 2.0. The default value is 1.0
PageCounterSize It represents the maximum number of digits for page numbering placeholders. This value is used if the PageCounterAutoSize property is false. The default value is 2
PageNumberOffset An optional offset (positive or negative) applied to the current page number when replacing the {page_number} placeholder in the template content. The default value is 0
RenderedSize The template rendered size in PDF page determined during rendering
RunJavaScript Controls if the JavaScript in the HTML document is executed. The default value of this property is true and the JavaScript is executed
ShowInEvenPages Specifies whether the template should be displayed on even-numbered pages of the PDF document. In HTML to PDF conversion, if ShowOnlyInHtmlToPdfPages is true, the first page generated from HTML is considered odd, the second even, and so on. If ShowOnlyInHtmlToPdfPages is false, the same rule applies based on the final document. In PDF merging or editing, this refers to even-numbered pages in the final PDF. The default value is true
ShowInFirstPage Specifies whether the template should be displayed on the first page of the PDF document. In HTML to PDF conversion, the first page refers to the first page generated from HTML content if ShowOnlyInHtmlToPdfPages is true or to the first page of the final PDF document if ShowOnlyInHtmlToPdfPages is is false. In PDF merging or editing, it refers to the actual first page of the final PDF. The default value is
ShowInOddPages Specifies whether the template should be displayed on odd-numbered pages of the PDF document. In HTML to PDF conversion, if ShowOnlyInHtmlToPdfPages is true, the first page generated from HTML is considered odd, the second even, the third odd, and so on. If ShowOnlyInHtmlToPdfPages is false, the same rule applies but based on the entire document. In PDF merging or editing, this refers to odd-numbered pages in the final PDF. The default value is true
ShowOnlyInHtmlToPdfPages In the context of HTML to PDF conversion, specifies whether the template should be displayed only on the PDF pages generated by the HTML to PDF converter, or on all PDF pages, including external PDF pages and Table of Contents (TOC) pages. The default value is true
SkipVariablesParsing A performance hint indicating that the template HTML does not contain any variable placeholders such as {page_number} or {total_pages}. When set to true and the template is provided via URL, the converter can skip downloading and inspecting the HTML content and render the HTML directly from the URL. This can improve performance by avoiding unnecessary network and parsing operations. The default value is false
TotalPagesOffset An optional offset (positive or negative) applied to the total number of pages when replacing the {total_pages} placeholder in the template content. The default value is 0
VerticalAlign Specifies the vertical alignment of the template on the PDF page. Takes precedence over the Y coordinate when set to a value other than None. This property is ignored for header and footer templates. The default value is None
WaitBeforeConvert An additional time in seconds to wait before starting to render the template HTML content to allow more time to JavaScript to update the web page. The default value is 0
Width Gets or sets the width of the PDF template. This property is ignored for header and footer templates because the width is determined from PDF page width
X Gets or sets the X position of the template in the PDF pages relative to the top left of the page. This property is ignored for header and footer templates
Y Gets or sets the Y position of the template in the PDF pages relative to the top left of the page. This property is ignored for header and footer templates

Methods

Equals
(Inherited from Object)
Finalize
(Inherited from Object)
GetHashCode
(Inherited from Object)
GetType
(Inherited from Object)
MemberwiseClone
(Inherited from Object)
ToString
(Inherited from Object)

See Also