Click or drag to resize
Pdf Library for .NET

PdfHtmlElement Class

Represents a html element that can be added to a pdf page or document.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfPageElement
    SelectPdf.UniversalPdfElement
      SelectPdf.UniversalPdfHtmlElement

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntax
public sealed class PdfHtmlElement : PdfElement

The PdfHtmlElement type exposes the following members.

Constructors
 NameDescription
Public methodPdfHtmlElement(String) Creates an html element from a url.
Public methodPdfHtmlElement(String, String) Creates an html element from a html string.
Public methodPdfHtmlElement(Single, Single, String)Creates an html element at (x, y) from a url.
Public methodPdfHtmlElement(Single, Single, Single, String)Creates an html element at (x, y) with the specified width from a url.
Public methodPdfHtmlElement(Single, Single, String, String)Creates an html element at (x, y) from a html string.
Public methodPdfHtmlElement(Single, Single, Single, Single, String)Creates an html element at (x, y) with the specified size from a url.
Public methodPdfHtmlElement(Single, Single, Single, String, String)Creates an html element at (x, y) with the specified width from a html string.
Public methodPdfHtmlElement(Single, Single, Single, Single, String, String)Creates an html element at (x, y) with the specified size from a html string.
Top
Properties
 NameDescription
Public propertyActualText Gets or sets the exact text represented by this element (the structure element's /ActualText entry), used when the drawn glyphs do not map to readable text.
(Inherited from PdfPageElement)
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 propertyAlternateText Gets or sets the alternate text describing this element for assistive technology (the structure element's /Alt entry). Required on figures for PDF/UA conformance.
(Inherited from PdfPageElement)
Public propertyArtifact Gets or sets a value indicating whether this element is an artifact — decorative or layout content that carries no meaning and is excluded from the logical structure (backgrounds, rules, running headers). Takes precedence over TagType.
(Inherited from PdfPageElement)
Public propertyAuthenticationHTTP authentication credentials used when fetching the web page.
Public propertyBackColor Gets or sets the background fill color.
(Inherited from PdfElement)
Public propertyBlending Gets or sets the blending mode.
(Inherited from PdfElement)
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 propertyColorSpace Gets or sets the color space for the pdf element rendering.
(Inherited from PdfElement)
Public propertyConsoleLog Console log captured from the rendered web page. Populated after the element has been rendered onto a page; null beforehand.
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 propertyDrawBackground Render the web page background in the generated pdf. Default: true.
Public propertyEnableOfflineModePuts the browser into offline mode before navigation so all network requests fail. Default: False.
Public propertyExternalLinksEnabled Render external hyperlinks from the web page in the generated pdf. Default: true.
Public propertyForceOutOfProcess Runs this element's rendering in a separate engine process, whatever ChromiumEngineHostMode says.
Public propertyForeColor Gets or sets the foreground color used for drawing outlines and text.
(Inherited from PdfElement)
Public propertyGradient Gets or sets the gradient fill. When set, overrides BackColor for fills.
(Inherited from PdfElement)
Public propertyHeight Gets or sets the destination height in points. A value of -1 (the default) lets the content flow onto the pages that follow, wherever the element starts: the first page holds what fits in the room left below Y, the pages after it are full pages, and the last one ends where the content ends. A fixed height taller than what is left of the page continues on the pages that follow until that much height has been drawn.
Public propertyHiddenWebElements Hidden web elements options applied during the inner html-to-pdf conversion. Available in the full edition.
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 propertyInternalLinksEnabled Convert internal hyperlinks (anchor links inside the page) 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 page of the generated PDF document. Default: 40.
Public propertyLazyImagesLoadingEnabled A flag indicating if the lazy loaded images are rendered in the generated pdf document. Default: True.
Public propertyLFN Path of the diagnostic log file written during conversion. When unset, no log is written.
Public propertyLineStyle Gets or sets the line style for outline drawing.
(Inherited from PdfElement)
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 propertyMaxConversionTimeTimeout in seconds for the print phase that produces the PDF after the page has loaded. 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 propertyPageRangesRestricts the rendered content to a subset of pages, e.g. "1", "2-4", "1-3,5,7-". Empty means all pages.
Public propertyPdfBookmarkOptions Bookmarks options applied during the inner html-to-pdf conversion. The bookmarks produced by the conversion are merged into the destination document at render time.
Public propertyPdfPagesRectangles Rectangles in the destination document where each slice of the rendered html landed, in client-area coordinates of the page that received the slice. Index 0 is the slice drawn on the host page at (X, Y); subsequent entries are the overflow slices drawn on appended pages at (0, 0). Populated after the element has been rendered onto a page; null beforehand.
Public propertyPostLoadingScript Javascript 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 propertyRotated Gets a value indicating whether a rotation has been applied.
(Inherited from PdfElement)
Public propertyScaled Gets a value indicating whether a scale has been applied.
(Inherited from PdfElement)
Public propertySkewed Gets a value indicating whether a skew has been applied.
(Inherited from PdfElement)
Public propertyStartupMode Controls how the conversion starts. Available in the full edition.
Public propertyStartupScript Javascript code injected into the page before any other script runs. Available in the full edition.
Public propertyTagged Produce tagged, accessible (PDF/UA-style) logical structure from this element's rendered content. The structure is taken from the rendering engine's own tagged output and re-mapped onto the host document as the element is stamped, exactly like the HtmlToPdf converter's Options.Tagged.
Public propertyTagType Gets or sets the structure type used to tag this element in a tagged (accessible) document. Ignored unless the document's tagged mode (PdfDocument.Tagged) is enabled. Null (default) leaves the element untagged unless Artifact is set.
(Inherited from PdfPageElement)
Public propertyTranslated Gets a value indicating whether a translation has been applied.
(Inherited from PdfElement)
Public propertyTransparency Gets or sets the transparency level (0 = completely transparent, 100 = completely opaque).
(Inherited from PdfElement)
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 propertyWebPageInformation Information about the rendered web page (size, scale factor). Populated after the element has been rendered onto a page; null beforehand.
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 destination width in points. A value of -1 (the default) fits the element to the available client width minus X.
Public propertyWindowStatusIf set, the converter waits for window.status to equal this value before capturing the page. Empty disables the wait.
Public propertyXGets or sets the element X position, in client-area coordinates.
Public propertyYGets or sets the element Y position, in client-area coordinates.
Top
Methods
 NameDescription
Public methodRotate Applies a rotation transformation.
(Inherited from PdfElement)
Public methodScale Applies a scale transformation.
(Inherited from PdfElement)
Public methodSkew Applies a skew transformation.
(Inherited from PdfElement)
Public methodTranslate Applies a translation transformation.
(Inherited from PdfElement)
Top
Remarks

The html can be specified by either a url or a html string and is converted at render time using an internal HtmlToPdf conversion. The result is drawn onto the destination page at (X, Y); when the rendered content overflows the available height, additional pages are appended automatically.

Coordinates and sizes are expressed in the page's client-area coordinate system — relative to the top-left corner of the writable area inside the page margins. Width defaults to the available client width minus X, Height defaults to the available client height minus Y.

Example
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
PdfHtmlElement html = new PdfHtmlElement(0, 0,
    "<h1>Invoice</h1><p>Thank you.</p>", "");
page.Add(html);
document.Save("out.pdf");
document.Close();
See Also