Class PdfGenerator
Concrete PDF generator. Mirrors the original CobaltPdf fluent surface and dispatches each render to a WebKitGTK subprocess. By default the subprocess runs inline from a bundled portable WebKit (auto-provisioned by BundleProvisioner); a Docker fallback exists for local dev.
public sealed class PdfGenerator : IPdfGenerator, IPdfGeneratorFinal
- Inheritance
-
PdfGenerator
- Implements
- Inherited Members
Constructors
PdfGenerator(IBrowserPoolManager, PdfOptions)
public PdfGenerator(IBrowserPoolManager pool, PdfOptions options)
Parameters
poolIBrowserPoolManageroptionsPdfOptions
Methods
AddCookie(string, string, string?, string)
public PdfGenerator AddCookie(string name, string value, string? domain = null, string path = "/")
Parameters
Returns
AddLocalStorage(string, string)
public PdfGenerator AddLocalStorage(string key, string value)
Parameters
Returns
AddSessionStorage(string, string)
public PdfGenerator AddSessionStorage(string key, string value)
Parameters
Returns
RenderHtmlAsPdfAsync(string, CancellationToken)
public Task<PdfDocument> RenderHtmlAsPdfAsync(string html, CancellationToken ct = default)
Parameters
htmlstringctCancellationToken
Returns
RenderHtmlFileAsPdfAsync(string, CancellationToken)
public Task<PdfDocument> RenderHtmlFileAsPdfAsync(string filePath, CancellationToken ct = default)
Parameters
filePathstringctCancellationToken
Returns
RenderUrlAsPdfAsync(string, CancellationToken)
public Task<PdfDocument> RenderUrlAsPdfAsync(string url, CancellationToken ct = default)
Parameters
urlstringctCancellationToken
Returns
WithCspBypass(bool)
public PdfGenerator WithCspBypass(bool enable = true)
Parameters
enablebool
Returns
WithCustomJS(string)
public PdfGenerator WithCustomJS(string script)
Parameters
scriptstring
Returns
WithEncryption(PdfEncryptionOptions)
public PdfGenerator WithEncryption(PdfEncryptionOptions e)
Parameters
Returns
WithFonts(string)
public PdfGenerator WithFonts(string dir)
Parameters
dirstring
Returns
WithFooter(string)
public PdfGenerator WithFooter(string htmlOrPath)
Parameters
htmlOrPathstring
Returns
WithGrayscale()
public PdfGenerator WithGrayscale()
Returns
WithHeader(string)
public PdfGenerator WithHeader(string htmlOrPath)
Parameters
htmlOrPathstring
Returns
WithHttpHeader(string, string)
public PdfGenerator WithHttpHeader(string name, string value)
Parameters
Returns
WithHttpHeaders(IDictionary<string, string>)
public PdfGenerator WithHttpHeaders(IDictionary<string, string> headers)
Parameters
headersIDictionary<string, string>
Returns
WithLandscape()
public PdfGenerator WithLandscape()
Returns
WithLazyLoadPages(int, TimeSpan?, TimeSpan?)
public PdfGenerator WithLazyLoadPages(int pageCount, TimeSpan? delay = null, TimeSpan? timeout = null)
Parameters
Returns
WithMargins(MarginOptions)
public PdfGenerator WithMargins(MarginOptions margins)
Parameters
marginsMarginOptions
Returns
WithMediaType(CssMediaType)
public PdfGenerator WithMediaType(CssMediaType type)
Parameters
typeCssMediaType
Returns
WithMetadata(Action<MetadataOptions>)
public PdfGenerator WithMetadata(Action<MetadataOptions> cfg)
Parameters
cfgAction<MetadataOptions>
Returns
WithPageRanges(string)
public PdfGenerator WithPageRanges(string ranges)
Parameters
rangesstring
Returns
WithPageSize(string, string)
public PdfGenerator WithPageSize(string width, string height)
Parameters
Returns
WithPaperFormat(string)
public PdfGenerator WithPaperFormat(string format)
Parameters
formatstring
Returns
WithPrintBackground(bool)
public PdfGenerator WithPrintBackground(bool enable = true)
Parameters
enablebool
Returns
WithReloadAfterStorage()
public PdfGenerator WithReloadAfterStorage()
Returns
WithScale(float)
public PdfGenerator WithScale(float scale)
Parameters
scalefloat
Returns
WithUserAgent(string)
public PdfGenerator WithUserAgent(string userAgent)
Parameters
userAgentstring
Returns
WithWaitStrategy(WaitOptions)
public PdfGenerator WithWaitStrategy(WaitOptions strategy)
Parameters
strategyWaitOptions
Returns
WithWatermark(WatermarkOptions)
public PdfGenerator WithWatermark(WatermarkOptions w)