Class HtmlToPdfBuilder
- Namespace
- SimpleSign.HtmlToPdf
- Assembly
- SimpleSign.HtmlToPdf.dll
Builder for configuring HTML-to-PDF conversion options. All methods return a new instance (immutable builder pattern).
public sealed class HtmlToPdfBuilder
- Inheritance
-
HtmlToPdfBuilder
- Inherited Members
Methods
Convert()
Converts the HTML to PDF and returns the PDF bytes.
public byte[] Convert()
Returns
- byte[]
Convert(Stream)
Converts the HTML to PDF and writes to the output stream.
public void Convert(Stream outputStream)
Parameters
outputStreamStream
ConvertAsync(Stream, CancellationToken)
Converts the HTML to PDF and writes to the output stream asynchronously.
public Task ConvertAsync(Stream outputStream, CancellationToken cancellationToken = default)
Parameters
outputStreamStreamcancellationTokenCancellationToken
Returns
ConvertAsync(CancellationToken)
Converts the HTML to PDF asynchronously and returns the PDF bytes.
public Task<byte[]> ConvertAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
SaveTo(string)
Converts the HTML to PDF and saves to a file.
public void SaveTo(string filePath)
Parameters
filePathstring
SaveToAsync(string, CancellationToken)
Converts the HTML to PDF and saves to a file asynchronously.
public Task SaveToAsync(string filePath, CancellationToken cancellationToken = default)
Parameters
filePathstringcancellationTokenCancellationToken
Returns
WithAuthor(string)
Sets the PDF document author metadata.
public HtmlToPdfBuilder WithAuthor(string author)
Parameters
authorstring
Returns
WithFooter(string)
Sets a footer template. Supports {page}, {pages}, {title}, {date} placeholders.
public HtmlToPdfBuilder WithFooter(string template)
Parameters
templatestring
Returns
WithHeader(string)
Sets a header template. Supports {page}, {pages}, {title}, {date} placeholders.
public HtmlToPdfBuilder WithHeader(string template)
Parameters
templatestring
Returns
WithMargins(float)
Sets uniform margins (in points, 1pt = 1/72 inch).
public HtmlToPdfBuilder WithMargins(float all)
Parameters
allfloat
Returns
WithMargins(float, float, float, float)
Sets margins individually (in points, 1pt = 1/72 inch).
public HtmlToPdfBuilder WithMargins(float top, float right, float bottom, float left)
Parameters
Returns
WithPageOrientation(PageOrientation)
Sets the page orientation for the output PDF.
public HtmlToPdfBuilder WithPageOrientation(PageOrientation orientation)
Parameters
orientationPageOrientation
Returns
WithPageSize(PageSize)
Sets the page size for the output PDF.
public HtmlToPdfBuilder WithPageSize(PageSize pageSize)
Parameters
pageSizePageSize
Returns
WithStylesheet(string)
Adds a CSS stylesheet to apply during conversion.
public HtmlToPdfBuilder WithStylesheet(string css)
Parameters
cssstring
Returns
WithTitle(string)
Sets the PDF document title metadata.
public HtmlToPdfBuilder WithTitle(string title)
Parameters
titlestring