PeachPDF

PeachPDF

PdfGenerateConfig Class

The settings for generating PDF using PdfGenerator

public sealed class PdfGenerateConfig

Inheritance System.Object → PdfGenerateConfig

Properties  
AllowLocalFileAccess Whether the document may reach the local file system. Defaults to true, preserving the historical behavior in which file: references are read from disk and relative references resolve against the current working directory. Set to false when rendering untrusted input, or in a host with no meaningful file system (a browser/WebAssembly app). Two things then change: every file: resource request resolves to “not found”, and a NetworkLoader with no BaseUri of its own (DataUriNetworkLoader and MimeKitNetworkLoader are both in this category) no longer inherits the working directory as a base — so a relative reference goes unresolved rather than being turned into a file: URI and read from disk. This covers every resource the document asks for — <img>, <link rel="stylesheet">, CSS url(), SVG <image href>, and @font-face src: url() — because they all resolve through one place. A deny wins even over an explicitly configured FileUriNetworkLoader. It does not restrict the root document, which is an input rather than a fetch: an HTML string passed to GeneratePdf, or a file a FileUriNetworkLoader was explicitly constructed with, is still read.
CompressContentStreams Gets or sets whether PDF content streams are compressed with FlateDecode. Defaults to true. Set to false to produce human-readable PDF streams, which is useful for testing or debugging.
DefaultLanguage A fallback language (e.g. "en-US") used for language-dependent rendering — currently hyphens: auto automatic hyphenation — only when the document itself declares none via <html lang="...">. A document’s own lang attribute always takes priority over this setting when present. Per the CSS Text spec, automatic hyphenation requires knowing the text’s language; PeachPDF never guesses one on its own, so a document with no lang and no DefaultLanguage set will not be automatically hyphenated. Set this when you know your content’s language out-of-band and want automatic hyphenation to apply anyway.
DownscaleImages When set to true (the default), a raster image whose decoded pixel size is larger than its on-page display size is resized down before being embedded in the PDF, shrinking output file size with no visible quality loss. Set to false to always embed images at their full decoded resolution, as PeachPDF did before this option existed.
DownscaleQuality The JPEG quality (0-100) used when DownscaleImages actually resizes an image that has no real alpha channel (and so would be JPEG-encoded anyway). Has no effect on full-resolution JPEG embeds, and never applies to images with real transparency - those stay on the lossless embed path regardless of downscaling, just resized. Defaults to 70.
EnableInteractivePdfForms When set to true, PeachPDF emits real, fillable AcroForm fields (text, checkbox, radio, select) for form elements whose resolved -peachpdf-pdf-form-field value requests one, instead of the default static box rendering. Defaults to false - an explicit, informed opt-in, exactly like EnableTaggedPdf.
EnableTaggedPdf When set to true, PeachPDF emits a PDF/UA-style tagged structure tree (StructTreeRoot, MarkInfo, per-element structure elements and marked content) alongside the visual content, mapping the HTML element tree to standard PDF structure types (see the -peachpdf-pdf-tag-type CSS property for how the mapping is controlled). Defaults to false — tagging adds a real amount of extra object-model bookkeeping per page, so it is an explicit, informed opt-in.
EnableXmpMetadata When set to true, PeachPDF emits an XMP metadata stream (the document catalog’s /Metadata entry) alongside the classic Document Information dictionary - useful for digital-asset-management/archival pipelines that read XMP directly. This is independent of PdfAConformance: a caller can opt into an XMP stream without requesting PDF/A conformance at all. Defaults to false. PdfAConformance being anything other than None forces an XMP stream to be written for that render regardless of this flag’s value (PDF/A requires one), without mutating this config object.
IgnoreAuthorStyleSheets When set to true, the document’s own author style sheets (its <style> elements and <link rel="stylesheet"> references) are ignored — only the user-agent default styles and any caller-supplied stylesheet (the cssData argument) are applied. Inline style attributes are not affected. Defaults to false.
ManualPageHeight if the page size is undefined this allows you to set manually the page height in points
ManualPageWidth if the page size is undefined this allows you to set manually the page width in points
MarginBottom the bottom margin between the page end and the text
MarginLeft the left margin between the page start and the text
MarginRight the right margin between the page end and the text
MarginTop the top margin between the page start and the text
MaximumDownscaleMultiplier When DownscaleImages resizes an image, the resize target is the image’s on-page display size multiplied by this value, clamped to never exceed the image’s natural decoded size (downscaling never upscales). For example, an image displayed at 60x40 with a multiplier of 2.0 resizes to 120x80 - useful headroom for zooming or printing. Defaults to 1.0 (resize to exactly the display size).
Media The CSS media type the cascade matches @media rules against. Defaults to "print" (the appropriate media for paged output). Set to another value (e.g. "screen") to render as that media type instead.
Metadata Optional overrides for the generated PDF’s document-information metadata (title, author, subject, keywords, creator). When non-null, each non-null field overrides the corresponding value extracted from the HTML source; when null (the default) all metadata comes from the HTML.
MinContentWidth When set to a positive number, sets the PixelsPerInch to fit the minimum content width
NetworkLoader The resources to load network content for the renderer. If null is provided, then an implementation that loads only the default document and any resources with data: URIs is provided We ship with MimeKit (MHTML) and HttpClient based implementations that can be used instead.
PageOrientation the orientation of each page of the generated pdf
PageSize the page size to use for each page in the generated pdf
PdfAConformance The PDF/A (ISO 19005) conformance level to target. Defaults to None - no PDF/A-specific work is done (see None for exactly what that means). See PdfAConformance for what each other level requires, including PDF/A-1’s restriction on transparency and the accessible “A” levels’ language requirement. Requesting any level other than None implicitly enables an XMP metadata stream for that render regardless of EnableXmpMetadata.
PixelsPerInch the amount of pixels per inch. We always render at 72 points per inch, so this is used to determine how many pixels a point is
PreferredColorScheme The color scheme reported to @media (prefers-color-scheme: ...) queries. Defaults to Light; set to Dark to render the document’s dark-mode styles.
ScaleToPageSize When set to true, this renders the page and automatically scales PixelsPerInch to fit the page contents
ShrinkToFit When set to true, sets the PixelsPerInch to fit the page contents only if the page contents is larger than the window
Methods  
SetMargins(int) Set all 4 margins to the given value.