Click or drag to resize
Pdf Library for .NET

HtmlToPdfOptions Class

This class contains various options used for the html to pdf conversion (page size and orientation, margins, web page dimensions, JavaScript, css media type, compression, security, document information, and more).
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalHtmlToPdfOptions

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

The HtmlToPdfOptions type exposes the following members.

Constructors
 NameDescription
Public methodHtmlToPdfOptions 
Top
Properties
 NameDescription
Public propertyAccessibilityStandard Gets or sets the universal accessibility standard the produced document declares. The default is None.
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 propertyAuthentication Handles authentication options if the web page being converted requires authentication.
Public propertyChromiumEnginePath Gets or sets the full path of the directory containing the Chromium engine binaries.
Public propertyChromiumEngineTemporaryFilesPath Gets or sets the full path of a folder where the Chromium rendering engine will write temporary files.
Public propertyClickElementsDelayAfter Delay in milliseconds, after element click.
Public propertyClickElementsDelayBefore Delay in milliseconds, before element click.
Public propertyClickElementsSelectors Specifies elements from the web page that will be clicked before converting the page.
Public propertyColorSpace Gets or sets the color space of the generated pdf document.
Public propertyConversionDelay Additional time in seconds the converter waits after the web page has loaded, before it is rendered.
Public propertyCssMediaType Indicates what css styles are used when the web page is rendered.
Public propertyCustomCSS Use this property to specify some CSS styles that will be injected into the page that is converted.
Public propertyDenyLocalFileAccess A flag indicating if local files can be loaded during the conversion. The default value is False and local files can be loaded.
Public propertyDisplayFooter Controls if a custom footer is displayed in the generated pdf document.
Public propertyDisplayHeader Controls if a custom header is displayed in the generated pdf document.
Public propertyDrawBackground Gets or sets a flag indicating if the web page background is rendered in pdf.
Public propertyEnableOfflineMode Puts the browser into offline mode before navigation so all network requests fail.
Public propertyExternalLinksEnabled Controls the rendering of external hyperlinks in pdf.
Public propertyForceOutOfProcess Runs this conversion in a separate engine process, whatever ChromiumEngineHostMode says.
Public propertyGenerateSinglePagePdf Generate a single page PDF. The converter will automatically resize the PDF page to fit all the content in a single page.
Public propertyHiddenWebElements Gets a reference to the object that controls the visibility of some web elements in the generated pdf document.
Public propertyHttpCache Selects what the engine's HTTP cache keeps from this conversion for the next one.
Public propertyHttpCookies Gets the collection of custom HTTP cookies used for the conversion.
Public propertyHttpHeaders Get the collection of custom HTTP headers used for the conversion.
Public propertyHttpPostParameters Gets the collection of custom HTTP POST parameters used for the conversion.
Public propertyInternalLinksEnabled Controls the conversion of internal html links to internal pdf links.
Public propertyJavaScriptEnabled Enable scripts when rendering the url or html string.
Public propertyJpegCompressionEnabled Gets or sets a flag indicating if the JPEG compression is enabled or not for the images in the generated pdf document.
Public propertyJpegCompressionLevel Gets or sets the compression level of images in the generated pdf document.
Public propertyLanguage Gets or sets the natural language of the text in a tagged PDF (see Tagged), as a BCP 47 language tag such as en-US. When not set, defaults to en-US.
Public propertyLazyImagesLoadingDelay Delay per page, in milliseconds, for lazy images loading.
Public propertyLazyImagesLoadingEnabled Enables a delay mechanism to allow images to fully load.
Public propertyLFN Gets or sets the path of the diagnostic log file written during conversion. When unset, no log is written.
Public propertyLoginOptions Handle custom page login.
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 propertyMarginBottom The bottom margin of the pdf document.
Public propertyMarginLeft The left margin of the pdf document.
Public propertyMarginRight The right margin of the pdf document.
Public propertyMarginTop The top margin of the pdf document.
Public propertyMaxConversionTime The timeout in seconds for the print phase that produces the PDF after the page has loaded.
Public propertyStatic memberMaximumConcurrentConversions Maximum number of html to pdf conversions that can be performed simultaneously.
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 generated PDF to a subset of pages, e.g. "1", "2-4", "1-3,5,7-".
Public propertyPdfBookmarkOptions Gets a reference to the object that controls the bookmarks creation for the generated pdf document.
Public propertyPdfCompressionLevel This property controls the compression level of the generated pdf document.
Public propertyPdfDocumentInformation Gets a reference to the object that specifies the generated pdf document properties.
Public propertyPdfPageCustomSize This property can be used to specify a custom pdf document page size.
Public propertyPdfPageOrientation This property controls the page orientation of the generated pdf document pages.
Public propertyPdfPageSize This property controls the size of the generated document pages.
Public propertyPdfStandard Defines the pdf standard used by the generated pdf document.
Public propertyPostLoadingScript Use this property to specify some JavaScript code that will be injected into the page that is converted and executed after the page was fully loaded.
Public propertyPostLoadingScriptDelayAfter Delay in milliseconds, after post page loading javascript injection.
Public propertyProxyOptions Gets a reference to an object containing the proxy settings used to access the web page that is being converted.
Public propertyRenderingEngine Gets or sets the rendering engine used by the converter to load and render the HTML. Chromium binaries must be also installed using a different package.
Public propertyRenderPageOnTimeout A flag indicating if the page is rendered even if a navigation timeout occurs. The default value is False and a navigation timeout exception is raised.
Public propertySecurityOptions Gets a reference to the object that specifies the generated pdf document security settings.
Public propertyStartupMode Use this property to specify how the conversion starts.
Public propertyStartupScript Use this property to specify some JavaScript code that will be injected into the page that is converted.
Public propertyTagged Gets or sets a value indicating whether the produced document is a tagged (accessible) PDF carrying a logical-structure tree, suitable for PDF/UA. The default is false.
Public propertyTitle Gets or sets the document title recorded in the metadata of a tagged PDF (see Tagged). Accessible documents are required to declare a title.
Public propertyViewerPreferences Controls how the pdf document will appear in a pdf viewer (like Adobe Reader).
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 propertyWebElementsMappingOptions Gets a reference to the object controlling the retrieval of HTML elements position in the generated PDF. In order to retrieve the position in PDF for a list of HTML elements, the CssSelectors property of WebElementsMappingOptions must be set with an array of strings containing the selectors of the HTML elements. The positions of the HTML elements in the generated PDF document will be returned in the Result object.
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 propertyWindowStatus If set, the converter waits for window.status to equal this value before capturing the page.
Top
Remarks
The HtmlToPdf class defines a reference to an object of this type, exposed as Options. Configure it before calling one of the converter's convert methods.
Example
HtmlToPdf converter = new HtmlToPdf();
converter.Options.PdfPageSize = PdfPageSize.A4;
converter.Options.PdfPageOrientation = PdfPageOrientation.Portrait;
converter.Options.MarginLeft = 20;
converter.Options.WebPageWidth = 1024;
PdfDocument doc = converter.ConvertUrl("https://www.google.com");
doc.Save("out.pdf");
doc.Close();
See Also