Requires Small Business or Enterprise since 3.266.0; the public unit and method names are unchanged
Since 3.267.0, ValidatePdfRasterSource provides combined raw-file and native page-fact inspection of one original-byte snapshot without reserializing it
This method validates a native reserialization and native page facts; the reserialization can omit an original PDF/R footer marker, so use ValidatePdfRComplianceWithOptions on the original saved stream when checking exact delivered bytes, together with the page-fact checks required by the selected profile
function ValidatePdfR: TPdfRValidationResult; overload;
function ValidatePdfR(const Options: TPdfRValidationOptions): TPdfRValidationResult; overload;
ValidatePdfR combines a raw-file inspection with a live PDFium page-object pass for ISO 23504-1:2020
%PDF-raster-x.y marker, permitted headers, object-stream prohibition, catalog and Info dictionary white lists, and the §6.4.4 parity between every Info entry and its corresponding XMP property; the metadata stream and the trailer /ID array are optional on an unencrypted file/V 5 and /R 6 when encrypted-profile enforcement is enabledTPdfRValidationOptions.Default checks 72 through 2400 DPI, permits 0.5 point geometry tolerance, requires a full-page strip, and enforces the encrypted PDF 2.0 profile
The result is a TPdfRValidationResult record:
prc1 (PDF/R-1 marker found), prcNone (no marker), or prcUnknown (parse failed or document inactive)TPdfRValidationIssues set covering file markers, metadata, encryption profile, raster-only content, geometry, colour, resolution, and compression parametersConformance is a real PDF/R level and Issues is emptyThe method is read-only and restores the caller's active page after validation
/Prev chain in the last cross-reference section is reported as pvriIncrementalUpdateForbidden when the document has no signature value dictionary; a document that does carry one is not flagged, because deciding whether every revision was signature-only needs a per-revision object comparison that a byte-level pass cannot perform reliablyConformance at prc1 and clears pvriMissingVersionMarker; its position is judged separately by pvriVersionMarkerPositionInvalid, which requires the marker on the line immediately before the last startxref and tolerates only blank lines between themValidatePdfR on an inactive document returns prcUnknown with an empty issue set+00:00 as well as ZTPdfRValidationIssues set whose members include the file-level pvriMissingVersionMarker (absent %PDF-raster-1.0 footer marker), pvriBadHeader (a header outside the §6.2.2 unencrypted range %PDF-1.4 through %PDF-1.7, or a %PDF-2.0 header without /Encrypt per §6.2.3), and pvriMissingTrailerId (absent trailer /ID array on an encrypted file); pvriObjStmPresent (a forbidden /Type /ObjStm stream); the dictionary white-list pvriProhibitedCatalogEntry and pvriProhibitedInfoEntry; the metadata pvriMissingXmpMetadata (a catalog /Metadata reference whose stream is absent or unreadable), pvriInfoXmpMismatch (an Info entry whose value differs from its XMP property), and pvriMetadataInvalid (an Info entry with no corresponding XMP property); the encryption-profile pvriEncryptVersionMismatch and pvriEncryptedPdf20ProfileInvalid (encryption that is not the Standard handler with /V 5 and /R 6); and the page-level pvriBadMediaBox, pvriFontForbidden, pvriForbiddenImageFilter (a filter outside the §6.2.2 white list, including JPXDecode, or Crypt on an unencrypted file), pvriPageImageMismatch (a page carrying no strip image), pvriNonRasterPageContent, pvriStripGeometryInvalid, pvriImageColorInvalid, pvriImageResolutionInvalid, and pvriImageCompressionParametersInvalid; and the PDF/raster 1.0 structural pvriPageDictionaryInvalid (§6.5.1 page entry white list), pvriPageTreeNodeInvalid (§6.5.2 page tree node white list, root Parent forbidden), pvriPageResourcesInvalid (§6.5.5 XObject keys exactly strip0–stripN), pvriPageContentsInvalid (§6.5.7 single-stream Contents drawing a strip through q Q cm Do only), pvriImageDictionaryInvalid and pvriStripConsistencyInvalid (§6.6.1 image white list and cross-strip agreement on Width, ColorSpace, BitsPerComponent and Intent), pvriStripColorSpaceInvalid (§6.6.2–§6.6.4 colour profile and CalGray Gamma 2.2), pvriStripDecodeInvalid (§6.6.2 bitonal BlackIs1 and Decode), pvriStripFilterInvalid (§6.6.2–§6.6.4 strip filter and CCITTFaxDecode K -1), and pvriIccAlternateInvalid (§6.6.4 ICCBased Alternate other than DeviceRGB); and the PDF/raster 1.0 reference and annotation rules pvriIndirectReferenceInvalid (§6.2.4 an indirect reference carrying a non-zero generation number, or naming object 0 or one beyond the file's maximum object number), pvriVersionMarkerPositionInvalid (§5 the %PDF-raster-1.0 comment not on the line immediately before the last startxref), and pvriSignatureWidgetInvalid (§6.5.4 a page Annots entry that is not a Widget with FT Sig, or whose Rect is missing or has non-zero width or height)
uses System.TypInfo;
var
Outcome: TPdfRValidationResult;
Issue: TPdfRValidationIssue;
begin
Pdf1.FileName := 'C:\Incoming\scan.pdf';
Pdf1.Active := True;
Outcome := Pdf1.ValidatePdfR;
Memo1.Lines.Add('Level: ' + GetEnumName(TypeInfo(TPdfRConformance),
Ord(Outcome.Conformance)));
for Issue in Outcome.Issues do
Memo1.Lines.Add('- ' + GetEnumName(TypeInfo(TPdfRValidationIssue), Ord(Issue)));
end;