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 PdfRoundTripValidatorRemarks
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
| Name | Description |
|---|---|
| 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.csValidates the round trip of a document.
public static PdfRoundTripResult Validate(PdfDocument document, PdfSaveOptions? saveOptions = null, PdfReadOptions? readOptions = null)Parameters
documentPdfDocument- The document.
saveOptionsPdfSaveOptions?- The options of both saves, or
nullfor the default options. readOptionsPdfReadOptions?- The options to read the first output with, or
nullfor 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.csValidates the round trip of a file.
public static PdfRoundTripResult Validate(ReadOnlyMemory<byte> data, PdfReadOptions? readOptions = null, PdfSaveOptions? saveOptions = null)Parameters
dataReadOnlyMemory<byte>- The file.
readOptionsPdfReadOptions?- The options to read the file and the outputs with, or
nullfor the default options. saveOptionsPdfSaveOptions?- The options of both saves, or
nullfor 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.