Class HtmlToPdfConverter
- Namespace
- SimpleSign.HtmlToPdf
- Assembly
- SimpleSign.HtmlToPdf.dll
Main entry point for HTML-to-PDF conversion. Provides a fluent API for converting HTML strings or files into PDF documents.
public static class HtmlToPdfConverter
- Inheritance
-
HtmlToPdfConverter
- Inherited Members
Examples
// Simple conversion
byte[] pdf = HtmlToPdfConverter
.Html("<h1>Hello</h1><p>World</p>")
.Convert();
// With options
byte[] pdf = HtmlToPdfConverter
.Html(htmlContent)
.WithPageSize(PageSize.A4)
.WithMargins(top: 30, right: 25, bottom: 30, left: 25)
.WithStylesheet("body { font-size: 14px; }")
.Convert();
// From file
byte[] pdf = await HtmlToPdfConverter
.FileAsync("report.html")
.WithPageSize(PageSize.Legal)
.ConvertAsync();
Methods
File(string)
Creates a conversion builder from an HTML file.
public static HtmlToPdfBuilder File(string filePath)
Parameters
filePathstringPath to the HTML file.
Returns
- HtmlToPdfBuilder
A builder for configuring the conversion.
FileAsync(string, CancellationToken)
Creates a conversion builder from an HTML file asynchronously.
public static Task<HtmlToPdfBuilder> FileAsync(string filePath, CancellationToken cancellationToken = default)
Parameters
filePathstringPath to the HTML file.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<HtmlToPdfBuilder>
A builder for configuring the conversion.
Html(byte[])
Creates a conversion builder from HTML bytes (UTF-8).
public static HtmlToPdfBuilder Html(byte[] htmlBytes)
Parameters
htmlBytesbyte[]UTF-8 encoded HTML content.
Returns
- HtmlToPdfBuilder
A builder for configuring the conversion.
Html(string)
Creates a conversion builder from an HTML string.
public static HtmlToPdfBuilder Html(string html)
Parameters
htmlstringThe HTML content to convert.
Returns
- HtmlToPdfBuilder
A builder for configuring the conversion.