Class PdfLimits
- Namespace
- MiPdf
- Assembly
- MiPdf.dll
Resource limits that protect against malicious or broken documents (decompression bombs, huge images, CPU-intensive structures). Exceeding a limit raises a PdfException.
public sealed record PdfLimits : IEquatable<PdfLimits>
- Inheritance
-
PdfLimits
- Implements
- Inherited Members
Examples
// process-wide defaults (e.g. at application start)
PdfLimits.Default = PdfLimits.Default with { MaxDecodedStreamSize = 64 * 1024 * 1024 };
// stricter limits for one request (flows with async calls)
using (PdfLimits.Use(PdfLimits.Default with { MaxDecodedStreamSize = 16 * 1024 * 1024 }))
{
using var doc = PdfDocument.Open(upload);
text = doc.ExtractText();
}
Properties
Current
The limits in effect for the current execution context.
public static PdfLimits Current { get; }
Property Value
Default
Process-wide limits used when no scoped limits are active.
public static PdfLimits Default { get; set; }
Property Value
MaxCMapEntries
Maximum number of code mappings a single CMap may define, including ranges (default 1,000,000).
public long MaxCMapEntries { get; init; }
Property Value
MaxDecodedStreamSize
Maximum size of a decoded stream in bytes (default 256 MB).
public long MaxDecodedStreamSize { get; init; }
Property Value
MaxFiltersPerStream
Maximum number of filters applied to one stream (default 8).
public int MaxFiltersPerStream { get; init; }
Property Value
MaxImagePixels
Maximum number of pixels of an image that is decoded (default 100 megapixels).
public long MaxImagePixels { get; init; }
Property Value
Methods
Use(PdfLimits)
Applies limits to the current execution context until the returned object is disposed.
public static IDisposable Use(PdfLimits limits)
Parameters
limitsPdfLimits