GemBox.Pdf
  • Overview
  • Examples
  • Free version
  • Support
  • Pricing

    Show / Hide Table of Contents

    HtmlConverter Class

    Namespace:
    GemBox.Pdf.Html
    Assembly:
    GemBox.Pdf.Html.Core.dll

    Provides methods for converting HTML content to a PdfDocument using a Chrome-based HTML renderer.

    • C#
    • VB.NET
    public static class HtmlConverter
    Public Module HtmlConverter
    Inheritance:
    System.Object
    HtmlConverter

    Properties

    LogOutput

    Gets or sets the log output writer.

    • C#
    • VB.NET
    public static TextWriter LogOutput { get; set; }
    Public Shared Property LogOutput As TextWriter
    Property Value
    System.IO.TextWriter

    The log output writer.

    Remarks

    Setting this property to a non-null value enables logging. Logging is disabled by setting this property to null.

    Methods

    ConvertFileToPdfAsync(String)

    Asynchronously converts the HTML content located in the specified file to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertFileToPdfAsync(string path)
    Public Shared Function ConvertFileToPdfAsync(path As String) As Task(Of PdfDocument)
    Parameters
    path
    System.String

    The file path to the HTML.

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    ConvertFileToPdfAsync(String, ConversionOptions)

    Asynchronously converts the HTML content located in the specified file to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertFileToPdfAsync(string path, ConversionOptions conversionOptions)
    Public Shared Function ConvertFileToPdfAsync(path As String, conversionOptions As ConversionOptions) As Task(Of PdfDocument)
    Parameters
    path
    System.String

    The file path to the HTML.

    conversionOptions
    ConversionOptions

    Options that customize the conversion

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    ConvertFileToPdfAsync(String, ConversionOptions, CancellationToken)

    Asynchronously converts the HTML content located in the specified file to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertFileToPdfAsync(string path, ConversionOptions conversionOptions, CancellationToken cancellationToken)
    Public Shared Function ConvertFileToPdfAsync(path As String, conversionOptions As ConversionOptions, cancellationToken As CancellationToken) As Task(Of PdfDocument)
    Parameters
    path
    System.String

    The file path to the HTML.

    conversionOptions
    ConversionOptions

    Options that customize the conversion

    cancellationToken
    System.Threading.CancellationToken

    The token to monitor for cancellation requests.

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    System.OperationCanceledException

    The operation was cancelled.

    ConvertFileToPdfAsync(String, CancellationToken)

    Asynchronously converts the HTML content located in the specified file to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertFileToPdfAsync(string path, CancellationToken cancellationToken)
    Public Shared Function ConvertFileToPdfAsync(path As String, cancellationToken As CancellationToken) As Task(Of PdfDocument)
    Parameters
    path
    System.String

    The file path to the HTML.

    cancellationToken
    System.Threading.CancellationToken

    The token to monitor for cancellation requests.

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    System.OperationCanceledException

    The operation was cancelled.

    ConvertHtmlToPdfAsync(String)

    Asynchronously converts the specified HTML string to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertHtmlToPdfAsync(string html)
    Public Shared Function ConvertHtmlToPdfAsync(html As String) As Task(Of PdfDocument)
    Parameters
    html
    System.String

    The HTML content to convert.

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    ConvertHtmlToPdfAsync(String, ConversionOptions)

    Asynchronously converts the specified HTML string to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertHtmlToPdfAsync(string html, ConversionOptions conversionOptions)
    Public Shared Function ConvertHtmlToPdfAsync(html As String, conversionOptions As ConversionOptions) As Task(Of PdfDocument)
    Parameters
    html
    System.String

    The HTML content to convert.

    conversionOptions
    ConversionOptions

    Options that customize the conversion

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    ConvertHtmlToPdfAsync(String, ConversionOptions, CancellationToken)

    Asynchronously converts the specified HTML string to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertHtmlToPdfAsync(string html, ConversionOptions conversionOptions, CancellationToken cancellationToken)
    Public Shared Function ConvertHtmlToPdfAsync(html As String, conversionOptions As ConversionOptions, cancellationToken As CancellationToken) As Task(Of PdfDocument)
    Parameters
    html
    System.String

    The HTML content to convert.

    conversionOptions
    ConversionOptions

    Options that customize the conversion

    cancellationToken
    System.Threading.CancellationToken

    The token to monitor for cancellation requests.

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    System.OperationCanceledException

    The operation was cancelled.

    ConvertHtmlToPdfAsync(String, CancellationToken)

    Asynchronously converts the specified HTML string to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertHtmlToPdfAsync(string html, CancellationToken cancellationToken)
    Public Shared Function ConvertHtmlToPdfAsync(html As String, cancellationToken As CancellationToken) As Task(Of PdfDocument)
    Parameters
    html
    System.String

    The HTML content to convert.

    cancellationToken
    System.Threading.CancellationToken

    The token to monitor for cancellation requests.

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    System.OperationCanceledException

    The operation was cancelled.

    ConvertToPdfAsync(Stream)

    Asynchronously converts the specified HTML stream to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertToPdfAsync(Stream stream)
    Public Shared Function ConvertToPdfAsync(stream As Stream) As Task(Of PdfDocument)
    Parameters
    stream
    System.IO.Stream

    The HTML stream to convert.

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    ConvertToPdfAsync(Stream, ConversionOptions)

    Asynchronously converts the specified HTML stream to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertToPdfAsync(Stream stream, ConversionOptions conversionOptions)
    Public Shared Function ConvertToPdfAsync(stream As Stream, conversionOptions As ConversionOptions) As Task(Of PdfDocument)
    Parameters
    stream
    System.IO.Stream

    The HTML stream to convert.

    conversionOptions
    ConversionOptions

    Options that customize the conversion

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    ConvertToPdfAsync(Stream, ConversionOptions, CancellationToken)

    Asynchronously converts the specified HTML stream to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertToPdfAsync(Stream stream, ConversionOptions conversionOptions, CancellationToken cancellationToken)
    Public Shared Function ConvertToPdfAsync(stream As Stream, conversionOptions As ConversionOptions, cancellationToken As CancellationToken) As Task(Of PdfDocument)
    Parameters
    stream
    System.IO.Stream

    The HTML stream to convert.

    conversionOptions
    ConversionOptions

    Options that customize the conversion

    cancellationToken
    System.Threading.CancellationToken

    The token to monitor for cancellation requests.

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    System.OperationCanceledException

    The operation was cancelled.

    ConvertToPdfAsync(Stream, CancellationToken)

    Asynchronously converts the specified HTML stream to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertToPdfAsync(Stream stream, CancellationToken cancellationToken)
    Public Shared Function ConvertToPdfAsync(stream As Stream, cancellationToken As CancellationToken) As Task(Of PdfDocument)
    Parameters
    stream
    System.IO.Stream

    The HTML stream to convert.

    cancellationToken
    System.Threading.CancellationToken

    The token to monitor for cancellation requests.

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    System.OperationCanceledException

    The operation was cancelled.

    ConvertUrlToPdfAsync(String)

    Asynchronously converts the HTML content located at the specified URL to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertUrlToPdfAsync(string url)
    Public Shared Function ConvertUrlToPdfAsync(url As String) As Task(Of PdfDocument)
    Parameters
    url
    System.String

    The URL of the HTML content to convert.

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    ConvertUrlToPdfAsync(String, ConversionOptions)

    Asynchronously converts the HTML content located at the specified URL to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertUrlToPdfAsync(string url, ConversionOptions conversionOptions)
    Public Shared Function ConvertUrlToPdfAsync(url As String, conversionOptions As ConversionOptions) As Task(Of PdfDocument)
    Parameters
    url
    System.String

    The URL of the HTML content to convert.

    conversionOptions
    ConversionOptions

    Options that customize the conversion

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    ConvertUrlToPdfAsync(String, ConversionOptions, CancellationToken)

    Asynchronously converts the HTML content located at the specified URL to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertUrlToPdfAsync(string url, ConversionOptions conversionOptions, CancellationToken cancellationToken)
    Public Shared Function ConvertUrlToPdfAsync(url As String, conversionOptions As ConversionOptions, cancellationToken As CancellationToken) As Task(Of PdfDocument)
    Parameters
    url
    System.String

    The URL of the HTML content to convert.

    conversionOptions
    ConversionOptions

    Options that customize the conversion

    cancellationToken
    System.Threading.CancellationToken

    The token to monitor for cancellation requests.

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    System.OperationCanceledException

    The operation was cancelled.

    ConvertUrlToPdfAsync(String, CancellationToken)

    Asynchronously converts the HTML content located at the specified URL to a PdfDocument.

    • C#
    • VB.NET
    public static Task<PdfDocument> ConvertUrlToPdfAsync(string url, CancellationToken cancellationToken)
    Public Shared Function ConvertUrlToPdfAsync(url As String, cancellationToken As CancellationToken) As Task(Of PdfDocument)
    Parameters
    url
    System.String

    The URL of the HTML content to convert.

    cancellationToken
    System.Threading.CancellationToken

    The token to monitor for cancellation requests.

    Returns
    System.Threading.Tasks.Task<PdfDocument>

    A task that represents the asynchronous operation. The task result contains the created PdfDocument.

    Exceptions
    ChromeRenderingException

    The conversion failed.

    System.OperationCanceledException

    The operation was cancelled.

    EnsureDependenciesAsync()

    Ensures that the required Chrome dependencies are installed. Additional dependencies are currently needed only when running on Linux. Dependencies are downloaded and installed only if they are missing.

    • C#
    • VB.NET
    public static Task EnsureDependenciesAsync()
    Public Shared Function EnsureDependenciesAsync As Task
    Returns
    System.Threading.Tasks.Task

    A task that represents the asynchronous operation. On non-Linux systems, the task completes immediately.

    Exceptions
    ChromeRenderingException

    The dependencies couldn't be installed.

    EnsureDependenciesAsync(CancellationToken)

    Ensures that required Chrome dependencies are installed. Additional dependencies are currently needed only when running on Linux. Dependencies are downloaded and installed only if they are missing.

    • C#
    • VB.NET
    public static Task EnsureDependenciesAsync(CancellationToken cancellationToken)
    Public Shared Function EnsureDependenciesAsync(cancellationToken As CancellationToken) As Task
    Parameters
    cancellationToken
    System.Threading.CancellationToken

    The token to monitor for cancellation requests.

    Returns
    System.Threading.Tasks.Task

    A task that represents the asynchronous operation. On non-Linux systems, the task completes immediately.

    Exceptions
    ChromeRenderingException

    The dependencies couldn't be installed.

    System.OperationCanceledException

    The operation was cancelled.

    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.