Click or drag to resize
Pdf Library for .NET

PdfHtmlSection Class

Represents a html element that can be added to the header or footer templates of a pdf document.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfSectionElement
    SelectPdf.UniversalPdfHtmlSection

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntax
public class PdfHtmlSection : PdfSectionElement

The PdfHtmlSection type exposes the following members.

Constructors
 NameDescription
Public methodPdfHtmlSection(String) Creates a html section object from a url that can be added to the header or footer templates of a pdf document.
Public methodPdfHtmlSection(String, String) Creates a html section object from html string content that can be added to the header or footer templates of a pdf document.
Public methodPdfHtmlSection(Single, Single, String) Creates a html section object from a url that can be added to the header or footer templates of a pdf document.
Public methodPdfHtmlSection(Single, Single, Single, String) Creates a html section object from a url that can be added to the header or footer templates of a pdf document.
Public methodPdfHtmlSection(Single, Single, String, String) Creates a html section object from html string content that can be added to the header or footer templates of a pdf document.
Public methodPdfHtmlSection(Single, Single, Single, String, String) Creates a html section object from html string content that can be added to the header or footer templates of a pdf document.
Top
Properties
 NameDescription
Public propertyAllowContentHeightResize A flag indicating if the content height can be recalculated to better fit the page. This can introduce certain errors in some cases. The default is True. Set it to False if content is split to more pages than expected.
Public propertyAuthenticationHTTP authentication credentials used when fetching the web page.
Public propertyBaseUrl Gets or sets the base url used to resolve relative paths in the html string.
Public propertyChromiumEnginePath The full path of the Chromium rendering engine used to render the html. When not set, the engine is resolved automatically from the application folder.
Public propertyChromiumEngineTemporaryFilesPath The path where the Chromium rendering engine writes its temporary files. When not set, the system temporary folder is used.
Public propertyClickElementsDelayAfterDelay in milliseconds after each element click. Default: 200.
Public propertyClickElementsDelayBeforeDelay in milliseconds before each element click. Default: 20.
Public propertyClickElementsSelectors Css selectors of elements to click before rendering. Useful for dismissing banners or expanding collapsed sections.
Public propertyConsoleLog The text written to the browser console by the converted web page during rendering. Populated after the section has been rendered.
Public propertyConversionDelay Additional time in seconds the converter waits after the web page has loaded, before it is rendered.
Public propertyCssMediaType Css media type used when rendering the html. Default: Screen.
Public propertyCustomCSSCustom css injected into the page before rendering.
Public propertyDenyLocalFileAccessDeny local file access during conversion. Default: false.
Public propertyDrawBackgroundRender the web page background. Default: true.
Public propertyEnableOfflineMode Puts the browser into offline mode before navigation so all network requests fail. Default: False.
Public propertyExternalLinksEnabledRender external hyperlinks from the web page. Default: true.
Public propertyForceOutOfProcess Runs this section's rendering in a separate engine process, whatever ChromiumEngineHostMode says.
Public propertyHeight Gets or sets the element height, in points, in the destination pdf page.
(Inherited from PdfSectionElement)
Public propertyHiddenWebElements Gets a reference to the object that controls the visibility of some web elements in the section.
Public propertyHtmlString Gets or sets the html string content to render in the header or footer.
Public propertyHttpCache Selects what the engine's HTTP cache keeps from this conversion for the next one.
Public propertyHttpCookiesCustom HTTP cookies sent when fetching the web page.
Public propertyHttpHeadersCustom HTTP headers sent when fetching the web page.
Public propertyHttpPostParametersCustom HTTP POST parameters sent when fetching the web page.
Public propertyInternalLinksEnabledConvert internal (anchor) hyperlinks into internal pdf links. Default: true.
Public propertyJavaScriptEnabledRun javascript when rendering the html. Default: true.
Public propertyLazyImagesLoadingDelay If LazyImagesLoadingEnabled is set to True, this property specifies the delay inserted for each rendered page. Default: 40.
Public propertyLazyImagesLoadingEnabled A flag indicating if the lazy loaded images are rendered in the generated content. Default: True.
Public propertyLFN Path of the diagnostic log file written during conversion. When unset, no log is written.
Public propertyLoginOptionsCustom-page login options used to authenticate before rendering.
Public propertyManagedContentTrimming Gets or sets whether the library decides where the rendered content ends on each page. Default: true.
Public propertyManagedContentTrimmingMode Gets or sets how the rendering engine finds where the content ends when ManagedContentTrimming is on. Default: Ink.
Public propertyMaxConversionTime Timeout in seconds for the print phase that produces the rendered header/footer content. Default: 60.
Public propertyMaxPageLoadTime The time in seconds to wait for the web page to load. Obsolete: use NavigationTimeout.
Obsolete
Public propertyMinPageLoadTime Additional time in seconds to wait before the web page is rendered. Obsolete: use ConversionDelay.
Obsolete
Public propertyNavigationTimeout The time in seconds the converter waits for the web page to load.
Public propertyPageRanges Restricts the rendered content to a subset of pages, e.g. "1", "2-4". Empty means all pages.
Public propertyPostLoadingScriptJavascript code injected and executed after the page has fully loaded.
Public propertyPostLoadingScriptDelayAfterDelay in milliseconds after post-loading script injection. Default: 20.
Public propertyProxyOptionsNetwork proxy options used when fetching the web page.
Public propertyRenderingEngine Gets or sets the rendering engine used to load and render the html.
Public propertyRenderPageOnTimeoutRender the page on timeout instead of throwing. Default: false.
Public propertyStartupModeControls when the conversion starts rendering the page.
Public propertyStartupScriptJavascript executed when StartupMode is Manual.
Public propertyTagged Gets or sets a flag indicating if the rendered html of the section is tagged (produces an accessible logical structure). The default value is false.
Public propertyUrl Gets or sets the url of the html page to render in the header or footer.
Public propertyVisibleWebElementId Convert only the html element with the specified id.
Obsolete
Public propertyVisibleWebElementSelector Convert only the part of the page matched by this CSS selector; the rest is ignored.
Public propertyWebGlEnabled Controls WebGL support in the rendering engine.
Public propertyWebPageFixedSizeControls whether the content below WebPageHeight is left out of the generated pdf document.
Public propertyWebPageHeightGets or sets the height of the converted web page as it would appear in the internal browser used to render the html.
Public propertyWebPageWidthGets or sets the width of the converted web page as it would appear in the internal browser used to render the html.
Public propertyWidth Gets or sets the element width, in points, in the destination pdf page.
(Inherited from PdfSectionElement)
Public propertyWindowStatus If set, the converter waits for window.status to equal this value before capturing the page. Empty disables the wait.
Public propertyX Gets or sets the element position on the X axis.
(Inherited from PdfSectionElement)
Public propertyY Gets or sets the element position on the Y axis.
(Inherited from PdfSectionElement)
Top
Remarks
The html can be specified by either an url or a html string. The html is rendered once using an internal HtmlToPdf conversion at the destination rectangle size and the resulting first page is drawn onto the header/footer of every page.
Example
HtmlToPdf converter = new HtmlToPdf();
converter.Options.DisplayHeader = true;
PdfHtmlSection html = new PdfHtmlSection(0, 0, "<b>My header</b>", "");
converter.Header.Add(html);
PdfDocument doc = converter.ConvertUrl("https://www.google.com");
doc.Save("out.pdf");
doc.Close();
See Also