Class ChromePdfRenderer
IronPdf.ChromePdfRenderer allows any web page or Html 'snippet' to be turned into a PDF document using an up-to-date embedded Chrome browser.
As of 2021 Iron Software recommend ChromePdfRenderer as our best PDF Renderer and a drop-in replacement for this class.
Implements
Namespace: IronPdf
Assembly: IronPdf.dll
Syntax
public class ChromePdfRenderer : ChromeClientAccessor, IExtensibleRenderer
Constructors
ChromePdfRenderer(IronPdfConnectionConfiguration)
Create a new Chrome Html To PDF renderer.
Declaration
public ChromePdfRenderer(IronPdfConnectionConfiguration ConnectionConfig = null)
Parameters
Type | Name | Description |
---|---|---|
IronPdfConnectionConfiguration | ConnectionConfig | Optional IronPdf host connection configuration |
Properties
LoginCredentials
Http login credentials
Declaration
public ChromeHttpLoginCredentials LoginCredentials { get; set; }
Property Value
Type | Description |
---|---|
ChromeHttpLoginCredentials |
RenderingOptions
Html to Pdf rendering options
Declaration
public ChromePdfRenderOptions RenderingOptions { get; set; }
Property Value
Type | Description |
---|---|
ChromePdfRenderOptions |
Methods
ApplyCookies(String, ChromeHttpLoginCredentials)
Apply cookies to the global request context for a specific URL. Consider using CustomCookies instead
See RenderingOptions for more information
Declaration
public void ApplyCookies(string Url, ChromeHttpLoginCredentials Login)
Parameters
Type | Name | Description |
---|---|---|
System.String | Url | Url to apply cookies to |
ChromeHttpLoginCredentials | Login | Cookies to apply |
ApplyCookies(String, Dictionary<String, String>)
Apply cookies to the global request context for a specific URL. Consider using CustomCookies instead.
See RenderingOptions for more information
Declaration
public void ApplyCookies(string url, Dictionary<string, string> cookies)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Url to apply cookies to |
System.Collections.Generic.Dictionary<System.String, System.String> | cookies | Cookies to apply |
Remarks
Automatically sets default RequestContext of future renders to Global
Very sensitive to the correct base URL, often times setting CustomCookies will yield better results
RenderHtmlAsPdf(String, String, String)
Creates a PDF file from an Html string, and returns it as a PdfDocument.
IronPDF is a W3C standards compliant HTML rendering based on Google's Chromium browser. If your output PDF does not look as expected:
- Validate your HTML using https://validator.w3.org/ & CSS https://jigsaw.w3.org/css-validator/
- To debug HTML, Save your HTML string to a file and view in Chrome web browser's print preview which will work almost exactly as IronPDF.
- Read our detailed documentation on pixel perfect HTML to PDF: https://ironpdf.com/tutorials/pixel-perfect-html-to-pdf/
Declaration
public PdfDocument RenderHtmlAsPdf(string Html, string BaseUrlOrPath, string Proxy = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | Html | The Html to be rendered as a PDF. |
System.String | BaseUrlOrPath | Optional. Setting the BaseUBaseUrlOrPathRL property gives the relative file path or URL context for hyper-links, images, CSS and JavaScript files. |
System.String | Proxy | Optional. Specifies an Http proxy server. Use the pattern: http(s)://user-name:password@host:port |
Returns
Type | Description |
---|---|
PdfDocument |
RenderHtmlAsPdf(String, Uri, String)
Creates a PDF file from an Html string, and returns it as a PdfDocument.
IronPDF is a W3C standards compliant HTML rendering based on Google's Chromium browser. If your output PDF does not look as expected:
- Validate your HTML using https://validator.w3.org/ & CSS https://jigsaw.w3.org/css-validator/
- To debug HTML, Save your HTML string to a file and view in Chrome web browser's print preview which will work almost exactly as IronPDF.
- Read our detailed documentation on pixel perfect HTML to PDF: https://ironpdf.com/tutorials/pixel-perfect-html-to-pdf/
Declaration
public PdfDocument RenderHtmlAsPdf(string Html, Uri BaseUrl = null, string Proxy = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | Html | The Html to be rendered as a PDF. |
System.Uri | BaseUrl | Optional. Setting the BaseURL property gives the relative file path or URL context for hyper-links, images, CSS and JavaScript files. |
System.String | Proxy | Optional. Specifies an Http proxy server. Use the pattern: http(s)://user-name:password@host:port |
Returns
Type | Description |
---|---|
PdfDocument |
RenderHtmlAsPdfAsync(String, Uri)
Asynchronously creates a PDF file from a URL or local file path and returns it as a PdfDocument.
Asynchronous variant of RenderHtmlAsPdf(String, Uri, String)
Declaration
public Task<PdfDocument> RenderHtmlAsPdfAsync(string Html, Uri BaseUrl = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | Html | The Html to be rendered as a PDF. |
System.Uri | BaseUrl | Setting the BaseUrl property gives the relative context for hyper-links, images, CSS and JavaScript files. May point to a local directory or a remote URL. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<PdfDocument> |
RenderHtmlAsPdfForExtension(String)
Declaration
public IDocumentId RenderHtmlAsPdfForExtension(string Html)
Parameters
Type | Name | Description |
---|---|---|
System.String | Html |
Returns
Type | Description |
---|---|
IronSoftware.IDocumentId |
RenderHtmlAsPdfForExtensionAsync(String)
Declaration
public Task<IDocumentId> RenderHtmlAsPdfForExtensionAsync(string Html)
Parameters
Type | Name | Description |
---|---|---|
System.String | Html |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<IronSoftware.IDocumentId> |
RenderHtmlFileAsPdf(String)
Creates a PDF file from a local Html file, and returns it as a PdfDocument.
IronPDF is a W3C standards compliant HTML rendering based on Google's Chromium browser. If your output PDF does not look as expected:
- Validate your HTML file using https://validator.w3.org/ & CSS https://jigsaw.w3.org/css-validator/
- To debug HTML, view the file in Chrome web browser's print preview which will work almost exactly as IronPDF.
- Read our detailed documentation on pixel perfect HTML to PDF: https://ironpdf.com/tutorials/pixel-perfect-html-to-pdf/
Declaration
public PdfDocument RenderHtmlFileAsPdf(string FilePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | FilePath | Path to an Html to be rendered as a PDF. |
Returns
Type | Description |
---|---|
PdfDocument |
RenderHtmlFileAsPdfAsync(String)
Asynchronously creates a PDF file from a local Html file, and returns it as a PdfDocument.
Asynchronous variant of RenderHtmlFileAsPdf(String)
Declaration
public Task<PdfDocument> RenderHtmlFileAsPdfAsync(string FilePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | FilePath | Path to an Html to be rendered as a PDF. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<PdfDocument> |
RenderMarkdownFileAsPdf(String)
Creates a PDF file from a Markdown file and returns it as a PdfDocument.
Declaration
public PdfDocument RenderMarkdownFileAsPdf(string FilePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | FilePath | Path to an Markdown file to be rendered as a PDF. |
Returns
Type | Description |
---|---|
PdfDocument |
RenderMarkdownStringAsPdf(String)
Creates a PDF file from an Markdown string format and returns it as a PdfDocument.
Declaration
public PdfDocument RenderMarkdownStringAsPdf(string markdownString)
Parameters
Type | Name | Description |
---|---|---|
System.String | markdownString | Markdown string to be rendered as a PDF. |
Returns
Type | Description |
---|---|
PdfDocument |
RenderPdfDocumentFromFile(ChromePdfRenderOptions, ChromeHttpLoginCredentials, String)
Render a PDF document from the specified HTML file path
Declaration
public PdfDocument RenderPdfDocumentFromFile(ChromePdfRenderOptions Options, ChromeHttpLoginCredentials Login, string filePath)
Parameters
Type | Name | Description |
---|---|---|
ChromePdfRenderOptions | Options | Rendering options |
ChromeHttpLoginCredentials | Login | HTTP login credentials |
System.String | filePath | HTML file path |
Returns
Type | Description |
---|---|
PdfDocument | PDF document |
RenderRtfFileAsPdf(String)
Creates a PDF file from a RTF (rich text format) file and returns it as a PdfDocument.
Declaration
public PdfDocument RenderRtfFileAsPdf(string FilePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | FilePath | Path to an RTF file to be rendered as a PDF. |
Returns
Type | Description |
---|---|
PdfDocument |
RenderRtfStringAsPdf(String)
Creates a PDF file from an RTF (rich text format) string and returns it as a PdfDocument.
Declaration
public PdfDocument RenderRtfStringAsPdf(string RtfString)
Parameters
Type | Name | Description |
---|---|---|
System.String | RtfString | RTF string to be rendered as a PDF. |
Returns
Type | Description |
---|---|
PdfDocument |
RenderUrlAsPdf(String)
Creates a PDF file from a URL or local file path and returns it as a PdfDocument.
Declaration
public PdfDocument RenderUrlAsPdf(string UrlOrPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | UrlOrPath | Path to an Html to be rendered as a PDF. |
Returns
Type | Description |
---|---|
PdfDocument |
RenderUrlAsPdf(Uri)
Creates a PDF file from a URL or local file path and returns it as a PdfDocument.
Declaration
public PdfDocument RenderUrlAsPdf(Uri Url)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | Url | An absolute (fully formed) Uri. Points to the Html document to be rendered as a PDF. |
Returns
Type | Description |
---|---|
PdfDocument |
RenderUrlAsPdfAsync(String)
Asynchronously creates a PDF file from a URL or local file path and returns it as a PdfDocument.
Asynchronous variant of RenderUrlAsPdf(String)
Declaration
public Task<PdfDocument> RenderUrlAsPdfAsync(string UrlOrPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | UrlOrPath | Path or URL to an Html document to be rendered as a PDF. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<PdfDocument> |
RenderUrlAsPdfAsync(Uri)
Asynchronously creates a PDF file from a URL or local file path and returns it as a PdfDocument.
Asynchronous variant of RenderUrlAsPdf(Uri)
Declaration
public Task<PdfDocument> RenderUrlAsPdfAsync(Uri Url)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | Url | An absolute (fully formed) Uri. Points to the Html document to be rendered as a PDF. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<PdfDocument> |
RenderZipFileAsPdf(String, String)
Creates a PDF file from a local Zip file, and returns it as a PdfDocument.
IronPDF is a W3C standards compliant HTML rendering based on Google's Chromium browser. If your output PDF does not look as expected:
- Validate your HTML file using https://validator.w3.org/ & CSS https://jigsaw.w3.org/css-validator/
- To debug HTML, view the file in Chrome web browser's print preview which will work almost exactly as IronPDF.
- Read our detailed documentation on pixel perfect HTML to PDF: https://ironpdf.com/tutorials/pixel-perfect-html-to-pdf/
Declaration
public PdfDocument RenderZipFileAsPdf(string FilePath, string MainFile)
Parameters
Type | Name | Description |
---|---|---|
System.String | FilePath | Path to an Zip to be rendered as a PDF. |
System.String | MainFile | Name of the primary HTML file. |
Returns
Type | Description |
---|---|
PdfDocument |
StaticRenderHtmlAsPdf(String, ChromePdfRenderOptions, String)
Creates a PDF file from an Html string, and returns it as an PdfDocument object which can be edited and saved to disk or served on a website.
Static version of the RenderHtmlAsPdf method.
Declaration
public static PdfDocument StaticRenderHtmlAsPdf(string Html, ChromePdfRenderOptions Options = null, string Proxy = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | Html | The Html to be rendered as a PDF. |
ChromePdfRenderOptions | Options | An instance of ChromePdfRenderOptions that allows configuration of Chrome "HTML to PDF" rendering parameters. |
System.String | Proxy | Specifies an Http proxy server. Use the pattern: http(s)://user-name:password@host:port |
Returns
Type | Description |
---|---|
PdfDocument | A PdfDocument with the Html rendered as its contents. |
StaticRenderHtmlAsPdf(String, String, ChromePdfRenderOptions, String)
Creates a PDF file from an Html string, and returns it as an PdfDocument object which can be edited and saved to disk or served on a website.
Static version of the RenderHtmlAsPdf method.
Declaration
public static PdfDocument StaticRenderHtmlAsPdf(string Html, string BaseUrlOrPath, ChromePdfRenderOptions Options = null, string Proxy = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | Html | The Html to be rendered as a PDF. |
System.String | BaseUrlOrPath | Setting the BaseURL property gives the relative context for hyper-links, images, CSS and JavaScript files. May be a remote URL or local file path. |
ChromePdfRenderOptions | Options | An instance of ChromePdfRenderOptions that allows configuration of Chrome "HTML to PDF" rendering parameters. |
System.String | Proxy | Specifies an Http proxy server. Use the pattern: http(s)://user-name:password@host:port |
Returns
Type | Description |
---|---|
PdfDocument | A PdfDocument with the Html rendered as its contents. |
StaticRenderHtmlAsPdf(String, Uri, ChromePdfRenderOptions, String)
Creates a PDF file from an Html string, and returns it as an PdfDocument object which can be edited and saved to disk or served on a website.
Static version of the RenderHtmlAsPdf method.
Declaration
public static PdfDocument StaticRenderHtmlAsPdf(string Html, Uri BaseUrl, ChromePdfRenderOptions Options = null, string Proxy = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | Html | The Html to be rendered as a PDF. |
System.Uri | BaseUrl | Setting the BaseURL property gives the relative context for hyper-links, images, CSS and JavaScript files. May be a remote URL or local file path. |
ChromePdfRenderOptions | Options | An instance of ChromePdfRenderOptions that allows configuration of Chrome "HTML to PDF" rendering parameters. |
System.String | Proxy | Specifies an Http proxy server. Use the pattern: http(s)://user-name:password@host:port |
Returns
Type | Description |
---|---|
PdfDocument | A PdfDocument with the Html rendered as its contents. |
StaticRenderHtmlAsPdfAsync(String, Uri, ChromePdfRenderOptions)
Creates a PDF file from an Html string, and returns it as an PdfDocument object which can be edited and saved to disk or served on a website.
Static Async version of the RenderHtmlAsPdf method.
Declaration
public static Task<PdfDocument> StaticRenderHtmlAsPdfAsync(string Html, Uri BaseUrl = null, ChromePdfRenderOptions Options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | Html | The Html to be rendered as a PDF. |
System.Uri | BaseUrl | Setting the BaseURL property gives the relative context for hyper-links, images, CSS and JavaScript files. May be a remote URL or local file path. |
ChromePdfRenderOptions | Options | An instance of ChromePdfRenderOptions that allows configuration of Chrome "HTML to PDF" rendering parameters. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<PdfDocument> | A PdfDocument with the Html rendered as its contents. |
StaticRenderHTMLFileAsPdf(String, ChromePdfRenderOptions)
Renders an HTML file as a PDF file. Returns a PdfDocument object which may be edited and saved to disk or served on a website.
Static version of the RenderHTMLFileAsPdf method.
Declaration
public static PdfDocument StaticRenderHTMLFileAsPdf(string FilePath, ChromePdfRenderOptions Options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | FilePath | Path to an Html file. |
ChromePdfRenderOptions | Options | Optional print options and settings as an instance of ChromePdfRenderOptions. |
Returns
Type | Description |
---|---|
PdfDocument | A PdfDocument with the Html file rendered as its contents.. |
StaticRenderHTMLFileAsPdfAsync(String, ChromePdfRenderOptions)
Renders an HTML file as a PDF file. Returns a PdfDocument object which may be edited and saved to disk or served on a website.
Static Async version of the RenderHTMLFileAsPdf method.
Declaration
public static Task<PdfDocument> StaticRenderHTMLFileAsPdfAsync(string FilePath, ChromePdfRenderOptions Options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | FilePath | Path to an Html file. |
ChromePdfRenderOptions | Options | Optional print options and settings as an instance of ChromePdfRenderOptions. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<PdfDocument> | A PdfDocument with the Html file rendered as its contents. |
StaticRenderUrlAsPdf(String, ChromePdfRenderOptions)
Renders all Html and assets at a given Url into a PDF file using IronPdf's embedded Chrome browser as the rendering engine.
Static version of the RenderUrlAsPdf method.
Declaration
public static PdfDocument StaticRenderUrlAsPdf(string UrlOrPath, ChromePdfRenderOptions Options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | UrlOrPath | An absolute Url. Points to the Html document to be rendered as a PDF. |
ChromePdfRenderOptions | Options | Optional print options and settings as an instance of ChromePdfRenderOptions. |
Returns
Type | Description |
---|---|
PdfDocument | A PdfDocument with the Url rendered as its contents. |
StaticRenderUrlAsPdf(Uri, ChromePdfRenderOptions)
Renders all Html and assets at a given Url into a PDF file using IronPdf's embedded Chrome browser as the rendering engine.
Static version of the RenderUrlAsPdf method.
Declaration
public static PdfDocument StaticRenderUrlAsPdf(Uri Url, ChromePdfRenderOptions Options = null)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | Url | An absolute Uri. Points to the Html document or local file file to be rendered as a PDF. |
ChromePdfRenderOptions | Options | Optional print options and settings as an instance of ChromePdfRenderOptions. |
Returns
Type | Description |
---|---|
PdfDocument | A PdfDocument with the Url rendered as its contents. |
StaticRenderUrlAsPdfAsync(String, ChromePdfRenderOptions)
Renders all Html and assets at a given Url into a PDF file using IronPdf's embedded Chrome browser as the rendering engine.
Static Async version of the RenderUrlAsPdf method.
Declaration
public static Task<PdfDocument> StaticRenderUrlAsPdfAsync(string UrlOrPath, ChromePdfRenderOptions Options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | UrlOrPath | An absolute Url. Points to the Html document or local file to be rendered as a PDF. |
ChromePdfRenderOptions | Options | Optional print options and settings as an instance of ChromePdfRenderOptions. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<PdfDocument> | A PdfDocument with the Url rendered as its contents. |
StaticRenderUrlAsPdfAsync(Uri, ChromePdfRenderOptions)
Renders all Html and assets at a given Url into a PDF file using IronPdf's embedded Chrome browser as the rendering engine.
Static Async version of the RenderUrlAsPdf method.
Declaration
public static Task<PdfDocument> StaticRenderUrlAsPdfAsync(Uri Url, ChromePdfRenderOptions Options = null)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | Url | An absolute Uri. Points to the Html document or local file file to be rendered as a PDF. |
ChromePdfRenderOptions | Options | Optional print options and settings as an instance of ChromePdfRenderOptions. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<PdfDocument> | A PdfDocument with the Url rendered as its contents. |
StaticRenderZipFileAsPdf(String, String, ChromePdfRenderOptions)
Creates a PDF file from a local Zip file, and returns it as a PdfDocument.
IronPDF is a W3C standards compliant HTML rendering based on Google's Chromium browser. If your output PDF does not look as expected:
- Validate your HTML file using https://validator.w3.org/ & CSS https://jigsaw.w3.org/css-validator/
- To debug HTML, view the file in Chrome web browser's print preview which will work almost exactly as IronPDF.
- Read our detailed documentation on pixel perfect HTML to PDF: https://ironpdf.com/tutorials/pixel-perfect-html-to-pdf/
Declaration
public static PdfDocument StaticRenderZipFileAsPdf(string FilePath, string MainFile, ChromePdfRenderOptions Options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | FilePath | Path to an Zip to be rendered as a PDF. |
System.String | MainFile | Name of the primary HTML file. |
ChromePdfRenderOptions | Options | Optional print options and settings as an instance of ChromePdfRenderOptions. |
Returns
Type | Description |
---|---|
PdfDocument |
StaticRenderZipFileAsPdfAsync(String, String, ChromePdfRenderOptions)
Creates a PDF file from a local Zip file, and returns it as a PdfDocument.
IronPDF is a W3C standards compliant HTML rendering based on Google's Chromium browser. If your output PDF does not look as expected:
- Validate your HTML file using https://validator.w3.org/ & CSS https://jigsaw.w3.org/css-validator/
- To debug HTML, view the file in Chrome web browser's print preview which will work almost exactly as IronPDF.
- Read our detailed documentation on pixel perfect HTML to PDF: https://ironpdf.com/tutorials/pixel-perfect-html-to-pdf/
Static Async version of the RenderZipFileAsPdf method.
Declaration
public static Task<PdfDocument> StaticRenderZipFileAsPdfAsync(string FilePath, string MainFile, ChromePdfRenderOptions Options = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | FilePath | Path to a Zip to be rendered as a PDF. |
System.String | MainFile | Name of the primary HTML file. |
ChromePdfRenderOptions | Options | Optional print options and settings as an instance of ChromePdfRenderOptions. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<PdfDocument> |