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, but the validator accepts other locations to remain forgiving of slightly non-standard generators.Conformance = prcUnknown and an empty Issues set.%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;