Enterprise 版:需連結 FPdfEnterprise(搜尋路徑含 Lib\Enterprise);否則此方法會引發 EPdfEnterpriseRequired;請見 版本對照表
function ValidatePdfE: TPdfEValidationResult;
ValidatePdfE 會走訪開啟中的文件,尋找 ISO 24517-1:2008 定義的 PDF/E-1 檔案格式標記:
pdfe:ISO_PDFEVersion 的 XMP 中繼資料串流(§5 + §13.3)pdfaExtension:schemas 描述(XMP Specification 2004 的延伸結構描述要求,經 §13.1 繼承)/ISO_PDFEVersion,其值為文字字串(§5 SHALL)/ID 陣列(§6.2)xmp:CreateDate 與 xmp:ModifyDate 項目(經 §13.1 自 ISO 19005-1 §6.7 繼承)結果是一筆 TPdfEValidationResult 記錄:
pec1(找到 PDF/E-1 識別碼且非空)、pecNone(沒有 PDF/E 標記)或 pecUnknown(剖析失敗,或標記存在但值缺失)TPdfEValidationIssues 集合,內含零或多個值。檔案格式標記:pveiMissingXmpMetadata、pveiMissingPdfEIdentifier、pveiMissingExtensionSchema、pveiMissingInfoVersionEntry、pveiInfoVersionMismatch、pveiMissingTrailerId、pveiMissingXmpDates。內容禁止檢查:pveiLzwForbidden(存在 /LZWDecode 篩選器)、pveiJavaScriptForbidden(存在 /JavaScript 動作或名稱)、pveiFormFieldsForbidden 與 pveiEmbeddedFilesForbidden(保留:第 10 條允許 AcroForm、第 14 條允許內嵌檔案,兩者都不再引發;XFA 與 NeedAppearances 保留各自的值)、pveiOpiForbidden(存在 /OPI 或 /Alternates)、pveiPdfiumFontNotEmbedded(頁面使用的字型依 FPDFFont_GetIsEmbedded 判定未內嵌)。ISO 24517-1 硬性要求:pveiBadPdfVersion(檔頭不是 %PDF-1.6,§5 修正基準版本)、pveiMissingOutputIntent(目錄的 /OutputIntents 缺少或為空)、pveiMissingIccProfile(OutputIntent 缺少 /DestOutputProfile)、pveiFontNotEmbedded(有使用字型但未內嵌字型程式)。互動式表單檢查(第 10 條):pveiXfaPresent(AcroForm 頂層存在 /XFA 項目)、pveiNeedAppearancesTrue(AcroForm 頂層的 /NeedAppearances 解析為 true)。與 PDF/A 驗證器共用的位元組層級規則掃描:pveiHexStringOddDigits 與 pveiHexStringInvalidChar(§6.6 十六進位字串)、pveiExternalStreamRef(串流字典帶 /F、/FFilter 或 /FDecodeParms,§6.7)、pveiIntegerImplementationLimit、pveiNameOverLimit 與 pveiDeviceNOverLimit(§6.9 實作上限)、pveiDeviceNNChannel(帶 /NChannel 子類型的 DeviceN,§7.3.4)、pveiImageInterpolateTrue(§7.4)、pveiPostScriptForbidden(PostScript XObject,或帶 /PS 鍵或 /Subtype2 為 PS 的 form XObject,§7.5 與 §7.7)、pveiReferenceXObjectForbidden(§7.6)、pveiExtGStateTransferFunction(存在 /TR,或 /TR2 不是 Default,§7.9)、pveiUsageCategoryInvalid(選用內容 usage application 列出 CreatorInfo 或 User,§7.12)、pveiAnnotationFlagsViolation(註解缺 /F、缺 Print 位元,或設了 Hidden / Invisible / NoView,§9.3)、pveiForbiddenAction(/ImportForm、棄用的 set-state 或無動作,§11.1)、pveiXmpHeaderAttributes(xpacket 標頭中的 bytes= 或 encoding=,§13.4)、pveiMissingXmpRequiredProperties(xmpMM:DocumentID、xmpMM:VersionID、xmpMM:RenditionClass、xmp:MetadataDate、dc:title 任一缺少或長度為零,§13.5)、pveiMediaMustHaveParameters(帶 /MH 的媒體字典,§15.4)與 pveiAlternatePresentations(Names 字典的 /AlternatePresentations 項目,§15.5)Conformance 是實際的 PDF/E 等級且 Issues 為空時傳回 TrueValidatePdfE 是唯讀檢查 — 它不會修改文件,且可安全重複呼叫。在將 PDF/E 內容送入工程封存之前使用它,可呈現此程式庫能偵測到的不符合項目。若只是常見的「這是不是 PDF/E-1?」檢查而不需要問題清單,請改用較輕量的 PdfEConformance 屬性
pveiInfoVersionMismatch。當 Info 項目缺席時,驗證器只回報 pveiMissingInfoVersionEntry(不會出現虛假的不一致)Conformance = pecUnknown 且 Issues 集合為空的記錄
uses System.TypInfo;
var
Outcome: TPdfEValidationResult;
Issue: TPdfEValidationIssue;
begin
Pdf1.FileName := 'C:\Incoming\drawing.pdf';
Pdf1.Active := True;
Outcome := Pdf1.ValidatePdfE;
Memo1.Lines.Add('Level: ' + GetEnumName(TypeInfo(TPdfEConformance),
Ord(Outcome.Conformance)));
for Issue in Outcome.Issues do
Memo1.Lines.Add('- ' + GetEnumName(TypeInfo(TPdfEValidationIssue), Ord(Issue)));
end;