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(catalog /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(可选内容用途应用列出 CreatorInfo 或 User,§7.12)、pveiAnnotationFlagsViolation(注释缺 /F、缺 Print 位,或设置了 Hidden / Invisible / NoView,§9.3)、pveiForbiddenAction(/ImportForm、废弃的 set-state 或 no-op 动作,§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;