Class PdfSecurityLimits
Hard ceilings and defensive limits for parsing untrusted hostile PDF data. Protects against decompression bombs, cyclic object references, infinite recursion, and OOM.
public sealed class PdfSecurityLimits
- Inheritance
-
PdfSecurityLimits
- Inherited Members
Fields
Default
The default limits. Create an instance with init values to change some of them.
public static readonly PdfSecurityLimits Default
Field Value
MaxRenderPixelCount
Ceiling on the pixel count of one render buffer, shared by every raster backend (Direct2D,
WPF, Skia). Past it the stride x height product (4 bytes a pixel) leaves int range, so a
page whose MediaBox, UserUnit or requested resolution asks for more is refused with a
PdfResourceLimitException whose LimitName is
"MaxRenderPixelCount", before any buffer is allocated. Far above any real viewport or
export; zoomed-in views render regions. A constant, not a setting: the buffer size cannot
go past it.
public const long MaxRenderPixelCount = 536870911
Field Value
Properties
MaxCachedDisplayListCommands
Display-list cache budget per document, in total commands.
public long MaxCachedDisplayListCommands { get; init; }
Property Value
MaxCalculatorOperations
Maximum operators executed by a single Type 4 PostScript calculator evaluation.
public int MaxCalculatorOperations { get; init; }
Property Value
MaxCalculatorStackDepth
Maximum operand stack depth of a Type 4 PostScript calculator function.
public int MaxCalculatorStackDepth { get; init; }
Property Value
MaxColorSpaceNestingDepth
Maximum color space nesting depth (Indexed base, Separation/DeviceN alternate, named references).
public int MaxColorSpaceNestingDepth { get; init; }
Property Value
MaxCommandsPerPage
Maximum drawing commands per page display list.
public int MaxCommandsPerPage { get; init; }
Property Value
MaxDecodedStreamBytes
Maximum decoded stream expansion size in bytes (128 MB per stream).
public long MaxDecodedStreamBytes { get; init; }
Property Value
MaxDecompressionRatio
Maximum decompression expansion ratio (e.g. 500x).
public double MaxDecompressionRatio { get; init; }
Property Value
MaxFormXObjectDepth
Maximum Form XObject recursion depth (PDFium draws up to 40 levels too).
public int MaxFormXObjectDepth { get; init; }
Property Value
MaxFunctionNestingDepth
Maximum nesting depth of Type 3 stitching functions (and function arrays within them).
public int MaxFunctionNestingDepth { get; init; }
Property Value
MaxFunctionSamples
Maximum total sample values (prod(Size) x outputs) of a Type 0 sampled function.
public int MaxFunctionSamples { get; init; }
Property Value
MaxGlyphsPerPage
Maximum glyphs per page.
public long MaxGlyphsPerPage { get; init; }
Property Value
MaxGraphicsStateDepth
Maximum q nesting depth; deeper q operators are ignored (bounded recovery).
public int MaxGraphicsStateDepth { get; init; }
Property Value
MaxImagePixels
Maximum pixels of a single image (width × height).
public long MaxImagePixels { get; init; }
Property Value
MaxImagePixelsPerPage
Maximum total pixels of all images on one page.
public long MaxImagePixelsPerPage { get; init; }
Property Value
MaxNestingDepth
Maximum dictionary or array nesting depth.
public int MaxNestingDepth { get; init; }
Property Value
MaxObjectsCount
Maximum indirect object count to resolve per document.
public int MaxObjectsCount { get; init; }
Property Value
MaxOperatorsPerPage
Maximum content-stream operators executed per page, across Form XObjects and Type3 glyphs.
public long MaxOperatorsPerPage { get; init; }
Property Value
MaxPageBuildTime
Maximum wall-clock time to build one page display list.
public TimeSpan MaxPageBuildTime { get; init; }
Property Value
MaxPageTreeDepth
Maximum page tree depth before aborting recursion.
public int MaxPageTreeDepth { get; init; }
Property Value
MaxPathSegmentsPerPage
Maximum path segments per page.
public long MaxPathSegmentsPerPage { get; init; }
Property Value
MaxTokenLength
Maximum string or token length in bytes (64 MB).
public int MaxTokenLength { get; init; }
Property Value
MaxTrailerChainDepth
Maximum number of /Prev trailer links to follow. Real files stay far below it, even after
thousands of incremental saves. A longer chain, or a /Prev loop, makes the reader rebuild the
cross-reference data by scanning the file (the document then reports it was repaired).
public int MaxTrailerChainDepth { get; init; }
Property Value
MaxTrailerChainEntries
Maximum cross-reference entries read along the whole /Prev chain (all sections together).
Past it the reader rebuilds the cross-reference data by scanning the file instead.
public long MaxTrailerChainEntries { get; init; }
Property Value
MaxType3Depth
Maximum Type3 glyph procedure nesting (a Type3 glyph showing Type3 text).
public int MaxType3Depth { get; init; }