THotPDF.ValidatePDFA4 Method
对照受支持的 PDF/A-4 base、PDF/A-4e engineering 或 PDF/A-4f associated-file profile,校验生成或加载的对象图,并返回稳定的结构化诊断
声明
function ValidatePDFA4(
const Options: THPDFPDFA4ValidationOptions;
out Issues: THPDFPDFA4ValidationIssues): boolean; overload;
function ValidatePDFA4(
const Options: THPDFPDFA4ValidationOptions;
out Findings: THPDFComplianceFindings): boolean; overload;
单元
HPDFDoc
Profile and severity types
THPDFPDFA4Profile = (
p4pAutomatic,
p4pBase,
p4pEngineering,
p4pAssociatedFiles
);
THPDFPDFA4IssueSeverity = (
p4isWarning,
p4isError
);
THPDFPDFA4Profile 选择元数据推断或显式指定的合规 profile,THPDFPDFA4IssueSeverity 则区分建议性诊断和校验错误
Options
| 字段 | 用途 |
|---|---|
Profile | Selects automatic metadata-based detection, base, engineering, or associated-file validation |
MaxObjects | 限制对象图的迭代遍历规模,默认为 1,000,000 个对象 |
MaxIssues | 限制保留的诊断数量,默认为 1,024 条 |
MaxDecodedBytes | 限制累计解码的元数据、ICC 和内容流字节,默认 64 MiB |
MaxContentTokens | 限制累计内容流 token 数,默认 4,000,000 个 |
CheckEmbeddedFonts | 检查渲染所用的字体是否带有嵌入的字体程序 |
CheckAnnotationAppearances | Checks annotation flags and normal appearance streams |
CheckOptionalContent | Checks optional-content configuration names and uniqueness |
CheckColourSpaces | 检查绘制的设备色、ICC 配置文件、输出意图、默认值、图像、shading、表单和透明组 |
CheckTransparency | 检查绘制的 alpha、软蒙版、混合模式以及页面级混合空间覆盖 |
CheckCompositeFonts | 检查 Type 0 后代字体、CIDSystemInfo、CMap 兼容性和 CIDToGIDMap 约束 |
CheckMetadataPackets | 检查每个元数据流的 UTF-8、包头、RDF 封套和 PDF/A 标识约束 |
Diagnostics
每个 THPDFPDFA4ValidationIssue 都会报告严重级别、带命名空间的稳定代码、适用的 ISO 19005-4 条款、对象路径、对象编号、已知时的从 0 开始的页面索引,以及便于阅读的消息
THPDFComplianceFindings 重载通过共享的机器可读发现项模型暴露同样的遍历结果,profile 为 PDF/A-4,修复状态为 crsNotAttempted
The validator covers PDF 2.0 identification, trailer ID and encryption state, XMP UTF-8 and PDF/A identification, Info restrictions, output intents, font embedding, annotations and appearances, AcroForm restrictions, actions and additional actions, associated files, optional content, external references, and profile-specific 3D or attachment rules
颜色与透明度发现基于实际绘制操作符,而不只是颜色设置操作符;内容分词和解码流复用会被缓存,同时每次调用仍会为自己的页面或 Form 上下文评估继承的图形状态
解码字节、内容 token、对象和保留问题上限都会以稳定的 pdfa4.validation.* 发现 fail closed,不会让无界工作继续
示例
var
Options: THPDFPDFA4ValidationOptions;
Issues: THPDFPDFA4ValidationIssues;
begin
Options := THPDFPDFA4ValidationOptions.Default;
Options.Profile := p4pAutomatic;
if not PDF.ValidatePDFA4(Options, Issues) then
raise Exception.CreateFmt('%s at %s',
[String(Issues[0].Code), String(Issues[0].Path)]);
end;
Generation behavior
EndDoc 会对 '4'、'4E' 和 '4F' 自动运行校验器,并在仍有错误时于序列化之前抛出异常
PDF/A-4 生成时会省略 trailer 的 Info 条目;PDF/A-4f 始终创建必需的 EmbeddedFiles 名称树,且只有 PDF/A-4f 接受文件附件注释,此时嵌入流、Filespec、AF 关系、Catalog 的 AF 数组和名称树会一并输出