function ValidatePdfR: TPdfRValidationResult;
ValidatePdfR 會走訪已開啟文件,尋找 ISO 23504-1:2020 定義的檔案格式標記
%PDF-raster-x.y 版本識別註解(§5)。%PDF-1.4, %PDF-1.5, %PDF-1.6, or %PDF-1.7 (§6.2.2) for unencrypted files, or %PDF-2.0 (§6.2.3) for encrypted files./Type /ObjStm — §6.2.4).pvriProhibitedCatalogEntry).pvriProhibitedInfoEntry)./ID array.The result is a TPdfRValidationResult record:
prc1 (PDF/R-1 marker found), prcNone (no marker), or prcUnknown (parse failed or document inactive).TPdfRValidationIssues set with zero or more values: pvriMissingVersionMarker, pvriBadHeader, pvriObjStmPresent, pvriProhibitedCatalogEntry, pvriProhibitedInfoEntry, pvriInfoXmpMismatch, pvriMissingXmpMetadata, pvriMissingTrailerId.ValidatePdfR is a read-only file-format inspection. PDF/R-1 compliance has strict structural requirements that this method does not check — per-page Contents structure, MediaBox form, allowed filters, generation-zero indirect references, strip layout. Pair with a TWAIN Working Group PDF/R validator for those content-level checks.
%PDF-raster- 子字串。ISO 23504-1 §5 指出這個標記放在 trailer dictionary 與 startxref 之間,但為了容忍稍微不標準的產生器,驗證器也接受其他位置ValidatePdfR 會傳回 Conformance = prcUnknown 且 Issues 為空的記錄%PDF-2.0 header), so the validator does NOT flag the trailer /Encrypt key as a non-conformance. Source PDFs encrypted under PDF 1.x would still fail because of the header check.
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;