PdfRoundTripValidator Class

Checks that the writer is deterministic and keeps the document: the document is written, the output is read back and written again, and the two outputs are compared, byte by byte and by their structure.

public static class PdfRoundTripValidator

Remarks

The first output must keep the pages of the document (count, boxes, rotation, annotations, decoded content); the second output must have the same object graph as the first (PdfDocumentSummary.Digest) and the same bytes. The bytes of an encrypted document are not compared: each save encrypts with new random initialization vectors.

The validator saves the document as PdfDocument.ToByteArray does: the save writes what the document model keeps apart from the objects (outline, font subsets, conformance entries).

Methods

NameDescription
Validate(PdfDocument, PdfSaveOptions?, PdfReadOptions?)Validates the round trip of a document.
Validate(ReadOnlyMemory<byte>, PdfReadOptions?, PdfSaveOptions?)Validates the round trip of a file.

Validate overloads

Validate(PdfDocument, PdfSaveOptions?, PdfReadOptions?)

PdfRoundTripValidator.cs

Validates the round trip of a document.

public static PdfRoundTripResult Validate(PdfDocument document, PdfSaveOptions? saveOptions = null, PdfReadOptions? readOptions = null)
Parameters
document PdfDocument
The document.
saveOptions PdfSaveOptions?
The options of both saves, or null for the default options.
readOptions PdfReadOptions?
The options to read the first output with, or null for the default options. An encrypted document needs its password.
Returns

PdfRoundTripResult The result of the validation.

Exceptions
PdfException
The document cannot be read or written.
InvalidOperationException
The document cannot be written.

Validate(ReadOnlyMemory<byte>, PdfReadOptions?, PdfSaveOptions?)

PdfRoundTripValidator.cs

Validates the round trip of a file.

public static PdfRoundTripResult Validate(ReadOnlyMemory<byte> data, PdfReadOptions? readOptions = null, PdfSaveOptions? saveOptions = null)
Parameters
data ReadOnlyMemory<byte>
The file.
readOptions PdfReadOptions?
The options to read the file and the outputs with, or null for the default options.
saveOptions PdfSaveOptions?
The options of both saves, or null for the default options.
Returns

PdfRoundTripResult The result of the validation.

Exceptions
PdfException
The file cannot be read, or the document cannot be written.
InvalidOperationException
The document cannot be written.