Table of Contents

Class PdfGenerator

Namespace
CobaltPdf.WebKit
Assembly
CobaltPDF.WebKit.dll

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

pool IBrowserPoolManager
options PdfOptions

Methods

AddCookie(string, string, string?, string)

public PdfGenerator AddCookie(string name, string value, string? domain = null, string path = "/")

Parameters

name string
value string
domain string
path string

Returns

PdfGenerator

AddLocalStorage(string, string)

public PdfGenerator AddLocalStorage(string key, string value)

Parameters

key string
value string

Returns

PdfGenerator

AddSessionStorage(string, string)

public PdfGenerator AddSessionStorage(string key, string value)

Parameters

key string
value string

Returns

PdfGenerator

RenderHtmlAsPdfAsync(string, CancellationToken)

public Task<PdfDocument> RenderHtmlAsPdfAsync(string html, CancellationToken ct = default)

Parameters

html string
ct CancellationToken

Returns

Task<PdfDocument>

RenderHtmlFileAsPdfAsync(string, CancellationToken)

public Task<PdfDocument> RenderHtmlFileAsPdfAsync(string filePath, CancellationToken ct = default)

Parameters

filePath string
ct CancellationToken

Returns

Task<PdfDocument>

RenderUrlAsPdfAsync(string, CancellationToken)

public Task<PdfDocument> RenderUrlAsPdfAsync(string url, CancellationToken ct = default)

Parameters

url string
ct CancellationToken

Returns

Task<PdfDocument>

WithCspBypass(bool)

public PdfGenerator WithCspBypass(bool enable = true)

Parameters

enable bool

Returns

PdfGenerator

WithCustomJS(string)

public PdfGenerator WithCustomJS(string script)

Parameters

script string

Returns

PdfGenerator

WithEncryption(PdfEncryptionOptions)

public PdfGenerator WithEncryption(PdfEncryptionOptions e)

Parameters

e PdfEncryptionOptions

Returns

PdfGenerator

WithFonts(string)

public PdfGenerator WithFonts(string dir)

Parameters

dir string

Returns

PdfGenerator

WithFooter(string)

public PdfGenerator WithFooter(string htmlOrPath)

Parameters

htmlOrPath string

Returns

PdfGenerator

WithGrayscale()

public PdfGenerator WithGrayscale()

Returns

PdfGenerator

WithHeader(string)

public PdfGenerator WithHeader(string htmlOrPath)

Parameters

htmlOrPath string

Returns

PdfGenerator

WithHttpHeader(string, string)

public PdfGenerator WithHttpHeader(string name, string value)

Parameters

name string
value string

Returns

PdfGenerator

WithHttpHeaders(IDictionary<string, string>)

public PdfGenerator WithHttpHeaders(IDictionary<string, string> headers)

Parameters

headers IDictionary<string, string>

Returns

PdfGenerator

WithLandscape()

public PdfGenerator WithLandscape()

Returns

PdfGenerator

WithLazyLoadPages(int, TimeSpan?, TimeSpan?)

public PdfGenerator WithLazyLoadPages(int pageCount, TimeSpan? delay = null, TimeSpan? timeout = null)

Parameters

pageCount int
delay TimeSpan?
timeout TimeSpan?

Returns

PdfGenerator

WithMargins(MarginOptions)

public PdfGenerator WithMargins(MarginOptions margins)

Parameters

margins MarginOptions

Returns

PdfGenerator

WithMediaType(CssMediaType)

public PdfGenerator WithMediaType(CssMediaType type)

Parameters

type CssMediaType

Returns

PdfGenerator

WithMetadata(Action<MetadataOptions>)

public PdfGenerator WithMetadata(Action<MetadataOptions> cfg)

Parameters

cfg Action<MetadataOptions>

Returns

PdfGenerator

WithPageRanges(string)

public PdfGenerator WithPageRanges(string ranges)

Parameters

ranges string

Returns

PdfGenerator

WithPageSize(string, string)

public PdfGenerator WithPageSize(string width, string height)

Parameters

width string
height string

Returns

PdfGenerator

WithPaperFormat(string)

public PdfGenerator WithPaperFormat(string format)

Parameters

format string

Returns

PdfGenerator

WithPrintBackground(bool)

public PdfGenerator WithPrintBackground(bool enable = true)

Parameters

enable bool

Returns

PdfGenerator

WithReloadAfterStorage()

public PdfGenerator WithReloadAfterStorage()

Returns

PdfGenerator

WithScale(float)

public PdfGenerator WithScale(float scale)

Parameters

scale float

Returns

PdfGenerator

WithUserAgent(string)

public PdfGenerator WithUserAgent(string userAgent)

Parameters

userAgent string

Returns

PdfGenerator

WithWaitStrategy(WaitOptions)

public PdfGenerator WithWaitStrategy(WaitOptions strategy)

Parameters

strategy WaitOptions

Returns

PdfGenerator

WithWatermark(WatermarkOptions)

public PdfGenerator WithWatermark(WatermarkOptions w)

Parameters

w WatermarkOptions

Returns

PdfGenerator