Table of Contents

Class HtmlToPdfConverter

Namespace
EvoPdf
Assembly
evohtmltopdf.dll

This class is the main class of the HTML to PDF Converter which offers the necessary methods to create a PDF document from a web page at given URL or from a HTML string. The generated PDF document can be saved into a memory buffer or into a file

[ClassInterface(ClassInterfaceType.AutoDual)]
public class HtmlToPdfConverter
Inheritance
HtmlToPdfConverter
Derived
Inherited Members

Constructors

HtmlToPdfConverter()

Creates a HTML to PDF converter using the default width and height for the HTML viewer window. The default HTML viewer width is 1024 pixels and the default HTML viewer height is 0 which means the HTML viewer height will be automatically determined based on the HTML content and the HTML viewer width in order to make visible the whole HTML content. If the HTML content is not entirely visible in the HTML viewer at the default width of 1024 pixels, the ClipHtmlView property will control whether the HTML content is clipped to the width set for the HTML viewer or the HTML viewer width is automatically extended to make visible the whole HTML content. By default the ClipHtmlView property is false and the HTML viewer is automatically extended in width to make visible the whole HTML content. The width and height of the HTML viewer can also be controlled by the HtmlViewerWidth and HtmlViewerHeight properties of the HtmlToPdfConverter class.

public HtmlToPdfConverter()

HtmlToPdfConverter(int)

Creates a HTML to PDF converter using the specified width in pixels and the default height for the HTML viewer window. The default HTML viewer height is 0 which means the HTML viewer height will be automatically determined based on the HTML content and the HTML viewer width in order to make visible the whole HTML content. If the content is not entirely visible in the HTML viewer at the specified width, the ClipHtmlView property will control whether the HTML content is clipped or the HTML viewer width is automatically extended to make visible the whole HTML content. By default the ClipHtmlView property is false and the HTML viewer is automatically extended in width to make visible the whole HTML content. The width and height of the HTML viewer can also be controlled by the HtmlViewerWidth and HtmlViewerHeight properties of the HtmlToPdfConverter class.

public HtmlToPdfConverter(int htmlViewerWidth)

Parameters

htmlViewerWidth int

The HTML viewer width in pixels

HtmlToPdfConverter(int, int)

Creates a HTML to PDF using the specified width and height in pixels for the HTML viewer window. If the specified HTML viewer height is 0 the HTML viewer height will be automatically determined based on the HTML content and the HTML viewer width in order to make visible the whole HTML content. If the content is not entirely visible in the HTML viewer at the specified width, the ClipHtmlView property will control whether the HTML content is clipped or the HTML viewer width is automatically extended to make visible the whole HTML content. By default the ClipHtmlView property is false and the HTML viewer is automatically extended in width to make visible the whole HTML content. The width and height of the HTML viewer can also be controlled by the HtmlViewerWidth and HtmlViewerHeight properties of the HtmlToPdfConverter class

public HtmlToPdfConverter(int htmlViewerWidth, int htmlViewerHeight)

Parameters

htmlViewerWidth int

The HTML viewer width in pixels

htmlViewerHeight int

The HTML viewer height in pixels

Properties

AuthenticationOptions

This property can be set with an username and a password in order to authenticate to the web server before accessing the URL to be converted in HTML to PDF Converter. They can be used for example to resolve the IIS Integrated Windows Authentication or other types of IIS authentication.

public AuthenticationOptions AuthenticationOptions { get; }

Property Value

AuthenticationOptions

ClipHtmlView

If the HTML content is not entirely visible in the HTML viewer of the HTML to PDF converter at the specified width, this property will control whether the HTML content is clipped or the HTML viewer width is automatically extended to make visible the whole HTML content. The HTML viewer width is given by the HtmlViewerWidth property. The default value of this property is false.

public bool ClipHtmlView { get; set; }

Property Value

bool

ConversionDelay

An additional time in seconds to wait for asynchronous items to be completely loaded or for a web page redirect to finish before starting the rendering in HTML to PDF converter. Default value is 2.

public int ConversionDelay { get; set; }

Property Value

int

ConversionSummary

Offers summary information about the conversion process. After a successful conversion this property is initialized with an instance of the ConversionSummary class. If the conversion failed this property returns a null value.

public ConversionSummary ConversionSummary { get; }

Property Value

ConversionSummary

DefaultHtmlEncoding

The default HTML document text encoding to be used if there is no charset meta tag defined in the HTML document. By default this property is not set and an auto determined text encoding will be used by converter

public string DefaultHtmlEncoding { get; set; }

Property Value

string

DownloadAllResources

Gets or sets a flag indicating if the HTML to PDF converter should try to download all the resources even if this could cause a slower conversion. The default value is false.

public bool DownloadAllResources { get; set; }

Property Value

bool

Enable3DTransformations

Gets or sets a flag indicating if the accelerated CSS 3D transformations are enabled in the HTML to PDF converter. The default value is false

public bool Enable3DTransformations { get; set; }

Property Value

bool

EnableAccelerated2DCanvas

Gets or sets a flag indicating if the accelerated 2D canvas is enabled in the HTML to PDF converter. The default value is false

public bool EnableAccelerated2DCanvas { get; set; }

Property Value

bool

EnableHttp2

Gets or sets a flag indicating if the HTTP2 protocol is enabled in HTML to PDF converter. The property has effect only in NE version of the library. The default value is false

public bool EnableHttp2 { get; set; }

Property Value

bool

EnablePersistentStorage

Gets or sets a flag indicating if the persistent local storage is enabled in the HTML to PDF converter. The default value is false

public bool EnablePersistentStorage { get; set; }

Property Value

bool

EnableWebGL

Gets or sets a flag indicating if the WebGL is enabled in the HTML to PDF converter. The default value is false

public bool EnableWebGL { get; set; }

Property Value

bool

EvoInternalFileName

Sets the full path of evointernal.dat helper file of the HTML to PDF converter. By default this file is expected to be found in the same folder with evohtmltopdf.dll assembly.

public string EvoInternalFileName { set; }

Property Value

string

ExtensionsEnabled

Gets or sets a flag indicating if the HTML viewer extensions are executed during HTML to PDF conversion. The default value is false and no extension is executed. The Flash player for Mozilla Firefox must be installed in order to execute the flash content from HTML

public bool ExtensionsEnabled { get; set; }

Property Value

bool

HiddenHtmlElementsSelectors

Gets or sets the CSS selectors of the HTML elements to be excluded from rendering during HTML to PDF conversion

public string[] HiddenHtmlElementsSelectors { get; set; }

Property Value

string[]

HtmlDocumentInfo

Gets an object populated after conversion with the title, keywords, and description of the converted HTML document.

public HtmlDocumentInfo HtmlDocumentInfo { get; }

Property Value

HtmlDocumentInfo

HtmlElementsMappingOptions

Gets a reference to the object that can be used to obtain the position in PDF of the HTML elements rendered by the HTML to PDF converter. In order to retrieve the position in PDF for a list of HTML elements, the HtmlElementSelectors property of HtmlElementsMappingOptions class must be set with an array of strings containing the CSS selectors of the HTML elements you want to map. The positions of the HTML elements in the generated PDF document will be returned in the HtmlElementsMappingResult object after the element was added to the page.

public HtmlElementsMappingOptions HtmlElementsMappingOptions { get; }

Property Value

HtmlElementsMappingOptions

HtmlViewerHeight

Gets or sets the HTML viewer height in pixels in the HTML to PDF Converter . If the specified HTML viewer height is 0 the HTML viewer height will be automatically determined based on the HTML content and the HTML viewer width in order to make visible the whole HTML content. The HTML viewer width is given by the HtmlViewerWidth property of the HtmlToPdfConverter class. If the HTML content is not entirely visible in the HTML viewer at the specified width, the ClipHtmlView property will control whether the HTML content is clipped or the HTML viewer width is automatically extended to make visible the whole HTML content. The HTML viewer height can also be specified in the HtmlToPdfConverter class contructor. The default value is 0 to automatically determine the HTML viewer height based on the HTML content and the HTML viewer width.

public int HtmlViewerHeight { get; set; }

Property Value

int

HtmlViewerWidth

Gets or sets the preferred HTML viewer width in pixels in HTML to PDF converter. If the HTML content is not entirely visible in the HTML viewer at the specified width, the ClipHtmlView property will control whether the HTML content is clipped or the HTML viewer width is automatically extended to make visible the whole HTML content. By default the ClipHtmlView property is false and the HTML viewer is automatically extended in width to make visible the whole HTML content. The HTML viewer width can also be specified in the HtmlToPdfConverter class constructor. The default value is 1024 pixels.

public int HtmlViewerWidth { get; set; }

Property Value

int

HtmlViewerZoom

Gets or sets the HTML viewer zoom percentage in HTML to PDF Converter similar to zoom level in a browser. The default value of this property is 100

public int HtmlViewerZoom { get; set; }

Property Value

int

HttpPostFields

Returns the collection of HTTP POST fields to be used when accessing a web page in HTML to PDF converter. If there are elements in collection then the converter will make a POST request to the web page URL with the fields from this collection, otherwise it will make a GET request

public NameValueCollection HttpPostFields { get; }

Property Value

NameValueCollection

HttpRequestCookies

Gets a collection of custom HTTP cookies to be sent by the HTML to PDF converter to the web server when the web page to convert and the resources (image, css, etc) referenced by the web page are requested. A cookie is defined by a name and a value pair that can be added to the collection using the Add(string, string) method of the HttpRequestCookies property.

public NameValueCollection HttpRequestCookies { get; }

Property Value

NameValueCollection

HttpRequestHeaders

Gets a collection of custom HTTP headers to be sent by the HTML to PDF converter to the web server when the web page is requested from a URL. A custom HTTP header is defined by a name and a value pair that can be added to the collection using the Add(string, string) method of the HttpRequestHeaders property. The PersistentHttpRequestHeaders property can be set on true to instruct the converter to send the custom headers each time an external resource (image, css, etc) referenced by the web page is requested. By default the PersistentHttpRequestHeaders property is false and the custom headers are not automatically sent to the web server when the web page resources are requested. The custom HTTP headers can be used to define cookies, authentication options, URL referrer or any other HTTP header to be sent to the web browser. The preferred method to send cookies is to use the HttpRequestCookies property.

public NameValueCollection HttpRequestHeaders { get; }

Property Value

NameValueCollection

ImagePartSize

Gets or sets the maximum height in pixels of an image part in HTML to PDF converter

public int ImagePartSize { get; set; }

Property Value

int

ImpersonationOptions

The impersonation options applied during navigation in HTML to PDF converter

public ImpersonationOptions ImpersonationOptions { get; }

Property Value

ImpersonationOptions

InitialHtmlViewerHeight

Gets or sets the initial height in pixels of the HTML viewer in HTML to PDF converter. This value of this property is ignored if the HtmlViewerHeight property is set

public int InitialHtmlViewerHeight { get; set; }

Property Value

int

InterruptSlowJavaScript

Gets or sets a flag indicating if the slow JavaScript script should be interrupted in HTML to PDF converter. The default value is false and the scripts are not interrupted

public bool InterruptSlowJavaScript { get; set; }

Property Value

bool

JavaScriptEnabled

A flag indicating if JavaScript execution is enabled in HTML to PDF converter. The default is true.

public bool JavaScriptEnabled { get; set; }

Property Value

bool

LicenseKey

Gets or sets the license key string received from the vendor in HTML to PDF converter. If this property is null the converter will automatically enter in evaluation mode and a demo watermark will be displayed on the generated PDF document.

public string LicenseKey { get; set; }

Property Value

string

LocalFilesAccessEnabled

Gets or sets a flag indicating if the access to local files is enabled in the HTML to PDF converter. The default value is true

public bool LocalFilesAccessEnabled { get; set; }

Property Value

bool

ManualTriggeringConversionDelay

An additional time in seconds to wait after manual triggering before starting the rendering in HTML to PDF converter. Default value is 2.

public int ManualTriggeringConversionDelay { get; set; }

Property Value

int

MaxHtmlViewerHeight

Gets or sets the maximum height in pixels to be rendered from the HTML document by the HTML to PDF converter. The default value is 0 and the entire HTML document is rendered

public int MaxHtmlViewerHeight { get; set; }

Property Value

int

MediaType

Gets or sets the media type of the HTML document used by the HTML to PDF converter. The default media type is 'screen'. If you set this property with 'print' then the CSS properties defined in '@media print' rule will be used to render the document

public string MediaType { get; set; }

Property Value

string

MinHtmlViewerHeight

Gets or sets the minimum height in pixels to be rendered from HTML document by the HTML to PDF converter. This value of this property is ignored if the HtmlViewerHeight property is set

public int MinHtmlViewerHeight { get; set; }

Property Value

int

NavigationTimeout

The HTML to PDF converter navigation timeout in seconds. Default value is 60.

public int NavigationTimeout { get; set; }

Property Value

int

NavigatorUserAgent

The custom user agent to be used when accessing the HTML page. When this property is null or empty the default user agent is used

public string NavigatorUserAgent { get; set; }

Property Value

string

PdfBookmarkOptions

Gets a reference to the object controlling the bookmarks creation for the rendered PDF document generated by the HTML to PDF converter. In order to enable creation of bookmarks you have to set the HtmlElementSelectors property of PdfBookmarkOptions class with the CSS selectors of the HTML elements you want to bookmark.

public PdfBookmarkOptions PdfBookmarkOptions { get; }

Property Value

PdfBookmarkOptions

PdfConverterConcurrencyLevel

This static parameter gives the maximum number of threads in the current .NET application domain that can convert HTML to PDF simultaneously. This parameter must be set before the first conversion performed in the current application domain. When this property is set with a negative value or zero the concurrency level is maximum. The default value is 4.

public static int PdfConverterConcurrencyLevel { get; set; }

Property Value

int

PdfDocumentInfo

Gets a reference to the object to controlling the generated PDF document information like the document title, author, subject or creation date.

public PdfDocumentInfo PdfDocumentInfo { get; }

Property Value

PdfDocumentInfo

PdfDocumentOptions

Gets a reference to the object controlling the conversion process and the generated PDF document properties. This property can be used to control the PDF document margins, PDF compression level, JPEG compression level, the PDF page size and orientation, the PDF document headers and footers, conversion of the URLs to links in PDF, conversion of the HTML links with anchors to internal PDF links, true type fonts embedding, fit width and stretch to fit, conversion to a single PDF page, append or prepend external PDF documents.

public PdfDocumentOptions PdfDocumentOptions { get; }

Property Value

PdfDocumentOptions

PdfFooterOptions

Gets a reference to an object to control the generated PDF document footer options. The footer is displayed in the generated PDF document only if the ShowFooter property is true.

public PdfFooterOptions PdfFooterOptions { get; }

Property Value

PdfFooterOptions

PdfFormOptions

Gets a reference to the object controlling the automatic conversion of a HTML form to a PDF form in the generated PDF document

public PdfFormOptions PdfFormOptions { get; }

Property Value

PdfFormOptions

PdfHeaderOptions

Gets a reference to an object to control the generated PDF document header options. The header is displayed in the generated PDF document only if the ShowHeader property is true.

public PdfHeaderOptions PdfHeaderOptions { get; }

Property Value

PdfHeaderOptions

PdfSecurityOptions

Gets a reference to the object to controlling the generated PDF document security settings like user and owner password, restrict printing or editing of the generated PDF document.

public PdfSecurityOptions PdfSecurityOptions { get; }

Property Value

PdfSecurityOptions

PdfViewerPreferences

Gets a reference to the object controlling how the generated PDF is displayed by a PDF viewer.

public ViewerPreferences PdfViewerPreferences { get; }

Property Value

ViewerPreferences

PersistentHttpRequestHeaders

This property can be set on true to instruct the HTML to PDF converter to send the custom headers defined by the HttpRequestHeaders property each time an external resource (image, css, etc) referenced by the web page is requested. The default value of this property is true and the custom headers are automatically sent to the web server when the web page resources are requested.

public bool PersistentHttpRequestHeaders { get; set; }

Property Value

bool

PostScriptFontsEnabled

Gets or sets a flag indicating if the fonts with PostScript outlines are enabled in HTML during the HTML to PDF conversion. The default value is true

public bool PostScriptFontsEnabled { get; set; }

Property Value

bool

PrerenderEnabled

Gets or sets a flag indicating if the HTML to PDF converter should perform a pre-rendering. The default value is false

public bool PrerenderEnabled { get; set; }

Property Value

bool

ProxyOptions

Gets a reference to an object encapsulating the proxy options used by HTML to PDF converter to access the HTML document to convert.

public ProxyOptions ProxyOptions { get; }

Property Value

ProxyOptions

RenderedHtmlElementSelector

Get or set the CSS selector of the HTML element to be rendered to PDF by the HTML to PDF converter. If the selector selects multiple HTML elements, only the the first one will be converted. The CSS selector is case sensitive. If this property is not set then the entire HTML document is rendered

public string RenderedHtmlElementSelector { get; set; }

Property Value

string

SvgFontsEnabled

Gets or sets a flag indicating if the SVG fonts are enabled in HTML during the HTML to PDF conversion. The default value is false

public bool SvgFontsEnabled { get; set; }

Property Value

bool

TableOfContentsOptions

Gets a reference to the object controlling the automatic creation of a table of contents in the generated PDF document

public TableOfContentsOptions TableOfContentsOptions { get; }

Property Value

TableOfContentsOptions

TriggeringMode

The conversion triggering mode used by the HTML to PDF converter. The default value is ConversionDelay.

public TriggeringMode TriggeringMode { get; set; }

Property Value

TriggeringMode

WebFontsEnabled

Gets or sets a flag indicating if the Web Fonts are enabled in HTML during the HTML to PDF conversion. The default value is true

public bool WebFontsEnabled { get; set; }

Property Value

bool

XPSupplementalLanguages

A flag in HTML to PDF converter indicating if the supplemental languages (complex script, right-to-left, East Asian) support was enabled in Windows XP Regional and Language Options. The default value is false.

public bool XPSupplementalLanguages { get; set; }

Property Value

bool

Methods

ConvertHtml(string, string)

Converts a HTML string to PDF using a base URL to resolve external resources and returns the rendered PDF document into a memory buffer

public byte[] ConvertHtml(string htmlString, string baseUrl)

Parameters

htmlString string

The HTML string to convert to PDF

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

Returns

byte[]

A memory buffer containing the the generated PDF document

ConvertHtml(string, string, string)

Converts a HTML string to PDF using a base URL to resolve external resources and an internal links base URL and returns the rendered PDF document into a memory buffer

public byte[] ConvertHtml(string htmlString, string baseUrl, string internalLinksBaseUrl)

Parameters

htmlString string

The HTML string to convert to PDF

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

internalLinksBaseUrl string

The full URL of the HTML document referenced by the internal links from the HTML string

Returns

byte[]

A memory buffer containing the the generated PDF document

ConvertHtmlFile(string)

Converts a HTML file to PDF and returns the rendered PDF document into a memory buffer

public byte[] ConvertHtmlFile(string htmlFilePath)

Parameters

htmlFilePath string

The full path of the HTML file to convert to PDF

Returns

byte[]

A memory buffer containing the the generated PDF document

ConvertHtmlFileToFile(string, string)

Converts a HTML file to PDF and writes the rendered PDF document into a file

public void ConvertHtmlFileToFile(string htmlFilePath, string outFile)

Parameters

htmlFilePath string

The full path of the HTML file to convert to PDF

outFile string

The full path of the file where to write the rendered PDF document

ConvertHtmlFileToPdfDocumentObject(string)

Converts a HTML file to PDF and returns the rendered PDF document as an object of the Document class that can be further used in other operations requiring this type of objects

public Document ConvertHtmlFileToPdfDocumentObject(string htmlFilePath)

Parameters

htmlFilePath string

The full path of the HTML file to convert to PDF

Returns

Document

The created Document object

ConvertHtmlFileToStream(string, Stream)

Converts a HTML file to PDF and writes the rendered PDF document into a stream

public void ConvertHtmlFileToStream(string htmlFilePath, Stream outPdfStream)

Parameters

htmlFilePath string

The full path of the HTML file to convert to PDF

outPdfStream Stream

The output stream where to write the generated PDF document

ConvertHtmlStream(Stream, Encoding, string)

Converts a HTML string read from a stream to PDF using a base URL to resolve external resources and returns the rendered PDF document into a memory buffer

public byte[] ConvertHtmlStream(Stream htmlStream, Encoding textEncoding, string baseUrl)

Parameters

htmlStream Stream

The stream containing the HTML string to convert to PDF

textEncoding Encoding

The stream text encoding

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

Returns

byte[]

An array of bytes containing the binary representation of the PDF document.

ConvertHtmlStream(Stream, Encoding, string, string)

Converts a HTML string read from a stream to PDF using a base URL to resolve external resources and an internal links base URL and returns the rendered PDF document into a memory buffer

public byte[] ConvertHtmlStream(Stream htmlStream, Encoding textEncoding, string baseUrl, string internalLinksBaseUrl)

Parameters

htmlStream Stream

The stream containing the HTML string to convert to PDF

textEncoding Encoding

The stream text encoding

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

internalLinksBaseUrl string

The full URL of the HTML document referenced by the internal links from the HTML stream

Returns

byte[]

An array of bytes containing the binary representation of the PDF document.

ConvertHtmlStreamToFile(Stream, Encoding, string, string)

Converts a HTML string read from a stream to PDF using a base URL to resolve external resources and writes the rendered PDF document into a file

public void ConvertHtmlStreamToFile(Stream htmlStream, Encoding textEncoding, string baseUrl, string outFile)

Parameters

htmlStream Stream

The stream containing the HTML string to convert to PDF

textEncoding Encoding

The stream text encoding

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

outFile string

The full path of the file where to write the rendered PDF document

ConvertHtmlStreamToFile(Stream, Encoding, string, string, string)

Converts a HTML string read from a stream to PDF using a base URL to resolve external resources and an internal links base URL and writes the rendered PDF document into a file

public void ConvertHtmlStreamToFile(Stream htmlStream, Encoding textEncoding, string baseUrl, string internalLinksBaseUrl, string outFile)

Parameters

htmlStream Stream

The stream containing the HTML string to convert to PDF

textEncoding Encoding

The stream text encoding

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

internalLinksBaseUrl string

The full URL of the HTML document referenced by the internal links from the HTML stream

outFile string

The full path of the file where to write the rendered PDF document

ConvertHtmlStreamToPdfDocumentObject(Stream, Encoding, string)

Converts a HTML string read from a stream to PDF using a base URL to resolve external resources and returns the rendered PDF document as an object of the Document class that can be further used in other operations requiring this type of objects.

public Document ConvertHtmlStreamToPdfDocumentObject(Stream htmlStream, Encoding textEncoding, string baseUrl)

Parameters

htmlStream Stream

The stream containing the HTML string to convert to PDF

textEncoding Encoding

The stream text encoding

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

Returns

Document

The created Document object

ConvertHtmlStreamToPdfDocumentObject(Stream, Encoding, string, string)

Converts a HTML string read from a stream to PDF using a base URL to resolve external resources and an internal links and returns the rendered PDF document as an object of the Document class that can be further used in other operations requiring this type of objects.

public Document ConvertHtmlStreamToPdfDocumentObject(Stream htmlStream, Encoding textEncoding, string baseUrl, string internalLinksBaseUrl)

Parameters

htmlStream Stream

The stream containing the HTML string to convert to PDF

textEncoding Encoding

The stream text encoding

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

internalLinksBaseUrl string

The fully qualified URL of the HTML document referenced by the internal links from the HTML string

Returns

Document

The created Document object

ConvertHtmlStreamToStream(Stream, Encoding, string, Stream)

Converts a HTML string read from a stream to PDF using a base URL to resolve external resources and writes the rendered PDF document into a stream

public void ConvertHtmlStreamToStream(Stream htmlStream, Encoding textEncoding, string baseUrl, Stream outPdfStream)

Parameters

htmlStream Stream

The stream containing the HTML string to convert to PDF

textEncoding Encoding

The stream text encoding

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

outPdfStream Stream

The output stream where to save the generated PDF document

ConvertHtmlStreamToStream(Stream, Encoding, string, string, Stream)

Converts a HTML string read from a stream to PDF using a base URL to resolve external resources and an internal links base URL and writes the rendered PDF document into a stream

public void ConvertHtmlStreamToStream(Stream htmlStream, Encoding textEncoding, string baseUrl, string internalLinksBaseUrl, Stream outPdfStream)

Parameters

htmlStream Stream

The stream containing the HTML string to convert to PDF

textEncoding Encoding

The stream text encoding

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

internalLinksBaseUrl string

The full URL of the HTML document referenced by the internal links from the HTML stream

outPdfStream Stream

The output stream where to save the generated PDF document

ConvertHtmlToFile(string, string, string)

Converts a HTML string to PDF using a base URL to resolve external resources and writes the rendered PDF document into a file

public void ConvertHtmlToFile(string htmlString, string baseUrl, string outFile)

Parameters

htmlString string

The HTML string to convert to PDF

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

outFile string

The full path of the file where to write the rendered PDF document

ConvertHtmlToFile(string, string, string, string)

Converts a HTML string to PDF using a base URL to resolve external resources and an internal links base URL and writes the rendered PDF document into a file

public void ConvertHtmlToFile(string htmlString, string baseUrl, string internalLinksBaseUrl, string outFile)

Parameters

htmlString string

The HTML string to convert to PDF

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

internalLinksBaseUrl string

The full URL of the HTML document referenced by the internal links from the HTML string

outFile string

The full path of the file where to write the rendered PDF document

ConvertHtmlToPdfDocumentObject(string, string)

Converts a HTML string to PDF using a base URL to resolve external resources and returns the rendered PDF document as an object of the Document class that can be further used in other operations requiring this type of objects.

public Document ConvertHtmlToPdfDocumentObject(string htmlString, string baseUrl)

Parameters

htmlString string

The HTML string to convert to PDF

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

Returns

Document

The created Document object

ConvertHtmlToPdfDocumentObject(string, string, string)

Converts a HTML string to PDF using a base URL to resolve external resources and an internal links base URL and returns the rendered PDF document as an object of the Document class that can be further used in other operations requiring this type of objects.

public Document ConvertHtmlToPdfDocumentObject(string htmlString, string baseUrl, string internalLinksBaseUrl)

Parameters

htmlString string

The HTML string to convert to PDF

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

internalLinksBaseUrl string

The fully qualified URL of the HTML document referenced by the internal links from the HTML string

Returns

Document

The created Document object

ConvertHtmlToStream(string, string, Stream)

Converts a HTML string to PDF using a base URL to resolve external resources and writes the rendered PDF document into a stream

public void ConvertHtmlToStream(string htmlString, string baseUrl, Stream outPdfStream)

Parameters

htmlString string

The HTML string to convert to PDF

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

outPdfStream Stream

The output stream where to write the generated PDF document

ConvertHtmlToStream(string, string, string, Stream)

Converts a HTML string to PDF using a base URL to resolve external resources and an internal links base URL and writes the rendered PDF document into a stream

public void ConvertHtmlToStream(string htmlString, string baseUrl, string internalLinksBaseUrl, Stream outPdfStream)

Parameters

htmlString string

The HTML string to convert to PDF

baseUrl string

The base URL used to determine the full URL of the external resources like images, CSS, JavaScript and Web Font files referenced by relative URLs in HTML

internalLinksBaseUrl string

The full URL of the HTML document referenced by the internal links from the HTML string

outPdfStream Stream

The output stream where to write the generated PDF document

ConvertUrl(string)

Converts an URL to PDF and returns the rendered PDF document into a memory buffer

public byte[] ConvertUrl(string url)

Parameters

url string

The URL of the HTML document to convert to PDF. The full path of a HTML file in the local file system is accepted as an URL if necessary

Returns

byte[]

A memory buffer containing the the generated PDF document

ConvertUrlToFile(string, string)

Converts an URL to PDF and writes the rendered PDF document into a file

public void ConvertUrlToFile(string url, string outFile)

Parameters

url string

The URL of the HTML document to convert to PDF. The full path of a HTML file in the local file system is accepted as an URL if necessary

outFile string

The full path of the file where to write the rendered PDF document

ConvertUrlToPdfDocumentObject(string)

Converts an URL to PDF and returns the rendered PDF document as an object of the Document class that can be further used in other operations requiring this type of objects

public Document ConvertUrlToPdfDocumentObject(string url)

Parameters

url string

The URL of the HTML document to convert to PDF. The full path of a HTML file in the local file system is accepted as an URL if necessary

Returns

Document

The created Document object

ConvertUrlToStream(string, Stream)

Converts an URL to PDF and writes the rendered PDF document into a stream

public void ConvertUrlToStream(string url, Stream outPdfStream)

Parameters

url string

The URL of the HTML document to convert to PDF. The full path of a HTML file in the local file system is accepted as an URL if necessary

outPdfStream Stream

The output stream where to write the generated PDF document

GetPageCount(Stream)

A fast method to obtain the page count of a PDF document from the specified stream.

public static int GetPageCount(Stream pdfStream)

Parameters

pdfStream Stream

The stream containing the PDF document for which to get the page count.

Returns

int

The number of pages in the specified PDF document.

GetPageCount(string)

A fast method to obtain the page count of a PDF document from the specified file path.

public static int GetPageCount(string pdfFilePath)

Parameters

pdfFilePath string

The path of the PDF file for which to get the page count.

Returns

int

The number of pages in the specified PDF document.

Events

AfterRenderPdfPageEvent

The event is raised right after the HTML to PDF converter finished PDF page rendering. The PDF page configuration like size, orientation, header or footer is already defined and cannot be changed. In the handler of this event PDF elements can be added in the foreground of the rendered PDF page.

public event AfterRenderPdfPageDelegate AfterRenderPdfPageEvent

Event Type

AfterRenderPdfPageDelegate

BeforeRenderPdfPageEvent

The event is raised right before the page is rendered by HTML to PDF converter. The PDF page configuration like size, orientation, header or footer is already defined and cannot be changed. In the handler of this event PDF elements can be added in the background of the PDF page to be rendered.

public event BeforeRenderPdfPageDelegate BeforeRenderPdfPageEvent

Event Type

BeforeRenderPdfPageDelegate

NavigationCompletedEvent

The event is raised right after the converter finished the navigation and before rendering HTML content to PDF

public event NavigationCompletedDelegate NavigationCompletedEvent

Event Type

NavigationCompletedDelegate

PrepareRenderPdfPageEvent

The event is raised after the HTML to PDF converter created the PDF page and before starting rendering it. In the handler of this event the PDF page configuration like size, orientation, header or footer can still be changed before starting rendering.

public event PrepareRenderPdfPageDelegate PrepareRenderPdfPageEvent

Event Type

PrepareRenderPdfPageDelegate