Class PdfStructureReader
- Namespace
- SimpleSign.Pdf
- Assembly
- SimpleSign.Pdf.dll
Reads PDF structure to extract digital signature fields and their metadata. Supports classic xref tables, xref streams (PDF 1.5+), and FlateDecode compression.
public sealed class PdfStructureReader
- Inheritance
-
PdfStructureReader
- Inherited Members
Fields
MaxPdfSize
Maximum PDF file size supported (200 MB).
public const int MaxPdfSize = 209715200
Field Value
Methods
DetectPdfALevelAsync(Stream, ILogger?, CancellationToken)
Detects the PDF/A conformance level by scanning XMP metadata for pdfaid:part
and pdfaid:conformance elements.
public static Task<PdfALevel> DetectPdfALevelAsync(Stream pdfStream, ILogger? logger = null, CancellationToken cancellationToken = default)
Parameters
pdfStreamStreamloggerILoggercancellationTokenCancellationToken
Returns
GetDocMdpPermissionLevelAsync(Stream, ILogger?, CancellationToken)
Returns the DocMDP permission level from the PDF. 0 = no DocMDP, 1 = no changes allowed, 2 = form filling only, 3 = form filling and annotations.
public static Task<int> GetDocMdpPermissionLevelAsync(Stream pdfStream, ILogger? logger = null, CancellationToken cancellationToken = default)
Parameters
pdfStreamStreamloggerILoggercancellationTokenCancellationToken
Returns
IsDocMdpLockedAsync(Stream, ILogger?, CancellationToken)
Checks if the PDF has a DocMDP certification signature that prohibits further modifications. Returns true if the document is locked (permission level < 3).
public static Task<bool> IsDocMdpLockedAsync(Stream pdfStream, ILogger? logger = null, CancellationToken cancellationToken = default)
Parameters
pdfStreamStreamloggerILoggercancellationTokenCancellationToken
Returns
IsEncryptedAsync(Stream, ILogger?, CancellationToken)
Checks if the PDF is encrypted. Encrypted PDFs cannot be signed or validated by SimpleSign.
public static Task<bool> IsEncryptedAsync(Stream pdfStream, ILogger? logger = null, CancellationToken cancellationToken = default)
Parameters
pdfStreamStreamloggerILoggercancellationTokenCancellationToken
Returns
IsLinearized(ReadOnlySpan<byte>)
Detects if the PDF is linearized (§9.9). Linearized PDFs have a Linearized dictionary in the first object. This is informational — linearized PDFs are fully supported for signature operations since we always follow the startxref chain from the end of the file.
public static bool IsLinearized(ReadOnlySpan<byte> data)
Parameters
dataReadOnlySpan<byte>
Returns
ReadSignatureFieldsAsync(Stream, ILogger?, CancellationToken)
Reads all digital signature fields from a PDF stream. Parses the cross-reference table (classic or stream) and scans for /ByteRange dictionaries.
public static Task<IReadOnlyList<PdfSignatureField>> ReadSignatureFieldsAsync(Stream pdfStream, ILogger? logger = null, CancellationToken cancellationToken = default)
Parameters
pdfStreamStreamloggerILoggercancellationTokenCancellationToken
Returns
ReadSignedBytesAsync(Stream, PdfByteRange, ILogger?, CancellationToken)
Reads the signed byte ranges from a PDF stream, concatenating both segments. Used to compute the hash for signature verification.
public static Task<byte[]> ReadSignedBytesAsync(Stream pdfStream, PdfByteRange byteRange, ILogger? logger = null, CancellationToken cancellationToken = default)
Parameters
pdfStreamStreambyteRangePdfByteRangeloggerILoggercancellationTokenCancellationToken