原创|行业资讯|编辑:吉炜炜|2025-11-05 10:12:00.773|阅读 1 次
概述:创建易于访问且符合规范的 PDF 文档正成为各行各业日益重要的需求。在本篇bow中,我们将探讨如何使用 Text Control 的 .NET 库验证 PDF/UA 文档,轻松确保生成的 PDF 符合无障碍标准。
#慧都22周年庆大促·界面/图表报表/文档/IDE/IOT/测试等千款热门软控件火热促销中>>
相关链接:
创建易于访问且符合规范的 PDF 文档正成为各行各业日益重要的需求。在本篇博文中,我们将探讨如何使用 Text Control 的 .NET 库验证 PDF/UA 文档,轻松确保生成的 PDF 符合无障碍标准。TX Text Control 34.0 将允许开发人员直接生成 PDF/UA 和 PDF/A-3a 文档,这对于长期、合规的文档归档而言是一项重大进步。
PDF/UA(通用无障碍)制定了确保所有人都能访问 PDF 文档的标准,包括使用辅助技术(如屏幕阅读器)的用户。
PDF/UA 确保文档的结构、阅读顺序和元素描述得到正确定义,以便所有内容都能在语义上被理解。
另一方面,PDF/A-3a 是 ISO 标准化的归档 PDF 格式系列的一部分。它保证文档可以原封不动地复制,包括嵌入式附件和可访问内容(“a”代表“可访问性”)。
这两个标准都要求文档包含逻辑结构、语义标签和准确描述内容的元数据。
在生成 PDF/UA 文件或设计模板的过程中,一些标签或描述性元素经常会丢失或应用错误。即使文档在视觉上看起来没有问题,但它可能不符合无障碍或存档标准,因此无法通过合规性检查。
例如:
如果没有验证,这些问题很容易被忽视。
在 34.0 版本中,我们将引入一个验证库,旨在帮助开发人员检查生成的 PDF 文档的合规性。
该库分析:
它以结构化的 JSON 格式生成详细报告,并为控制台应用程序提供文本输出。这使得开发人员能够将验证直接集成到自动化测试或质量保证 (QA) 流程中。
以下是一个如何在 C# 应用程序中使用验证库的简单示例:
using TXTextControl.PDF.Validation;
var report = PdfUaValidator.Validate("documents/hyperlink.pdf");
report.PrintText();
在这个例子中,我们首先创建一个验证器实例,然后验证文档。验证结果会输出到控制台,并可以序列化为 JSON 格式以进行进一步分析。
生成的 JSON 报告详细概述了文档中发现的所有合规性问题:
{
"filePath": "documents/hyperlink.pdf",
"pdfVersion": "1.7",
"isPass": true,
"documentTitle": "This is a sample PDF/UA document",
"documentLanguage": "en-US",
"findings": [
{
"ruleId": "UA-CONFORMANCE",
"severity": "Info",
"passed": true,
"message": "PDF/UA-1 conformance declaration found in XMP."
},
{
"ruleId": "PDFA-CONFORMANCE",
"severity": "Info",
"passed": true,
"message": "PDF/A-3A declaration found in XMP."
},
{
"ruleId": "PDF-HEADER",
"severity": "Error",
"passed": true,
"message": "Found PDF header %PDF-1.7."
},
{
"ruleId": "PDF-XREF",
"severity": "Warning",
"passed": true,
"message": "Cross-reference table/stream appears present."
},
{
"ruleId": "UA-CATALOG",
"severity": "Error",
"passed": true,
"message": "Catalog dictionary present."
},
{
"ruleId": "UA-MARKED",
"severity": "Error",
"passed": true,
"message": "/MarkInfo \u003C\u003C /Marked true \u003E\u003E found (Tagged PDF)."
},
{
"ruleId": "UA-STRUCT",
"severity": "Error",
"passed": true,
"message": "/StructTreeRoot present."
},
{
"ruleId": "UA-MCID-ANCHOR",
"severity": "Info",
"passed": true,
"message": "Marked content (/MCID) present and at least one page has /StructParents anchors."
},
{
"ruleId": "UA-TEXT-MAPPING",
"severity": "Info",
"passed": true,
"message": "Font ToUnicode maps present (text is likely accessible)."
},
{
"ruleId": "UA-LANG",
"severity": "Error",
"passed": true,
"message": "/Lang present at document/page level."
},
{
"ruleId": "UA-METADATA",
"severity": "Warning",
"passed": true,
"message": "XMP metadata packet detected."
},
{
"ruleId": "UA-TITLE",
"severity": "Error",
"passed": true,
"message": "Document title found (Info or XMP dc:title)."
},
{
"ruleId": "UA-TABS",
"severity": "Warning",
"passed": true,
"message": "Page /Tabs setting present."
},
{
"ruleId": "UA-FIG-ALT",
"severity": "Info",
"passed": true,
"message": "Figures detected: 3; descriptive text tokens (/Alt or /ActualText): 3."
},
{
"ruleId": "UA-LINK-DESC",
"severity": "Info",
"passed": true,
"message": "Links: 2; all appear to have nearby tooltip/contents/ActualText."
},
{
"ruleId": "UA-FORMS-TU",
"severity": "Info",
"passed": true,
"message": "AcroForm detected; tooltips (/TU) count: 3."
},
{
"ruleId": "UA-TABLE-A-SUMMARY",
"severity": "Info",
"passed": true,
"message": "Tables: 3; all have /A with /Summary."
},
{
"ruleId": "UA-TABLE-HEADERS",
"severity": "Info",
"passed": true,
"message": "Tables with headers: OK=1, missing/invalid=0."
}
],
"tableSummaries": [
{
"index": 1,
"summaryText": "Table description",
"summaryRaw": "(\u00FE\u00FF\u0000T\u0000a\u0000b\u0000l\u0000e\u0000 \u0000d\u0000e\u0000s\u0000c\u0000r\u0000i\u0000p\u0000t\u0000i\u0000o\u0000n)",
"hasOTable": true,
"source": "Obj 58: A 74 0 R",
"thTotal": 3,
"thWithScope": 3,
"tdWithHeaders": 0,
"headersOk": true,
"headersApplicable": true
},
{
"index": 2,
"summaryText": "Inner table",
"summaryRaw": "(\u00FE\u00FF\u0000I\u0000n\u0000n\u0000e\u0000r\u0000 \u0000t\u0000a\u0000b\u0000l\u0000e)",
"hasOTable": true,
"source": "Obj 59: A 96 0 R",
"thTotal": 0,
"thWithScope": 0,
"tdWithHeaders": 0,
"headersOk": true,
"headersApplicable": false
},
{
"index": 3,
"summaryText": "Third table",
"summaryRaw": "(\u00FE\u00FF\u0000T\u0000h\u0000i\u0000r\u0000d\u0000 \u0000t\u0000a\u0000b\u0000l\u0000e)",
"hasOTable": true,
"source": "Obj 60: A 122 0 R",
"thTotal": 0,
"thWithScope": 0,
"tdWithHeaders": 0,
"headersOk": true,
"headersApplicable": false
}
],
"links": [
{
"index": 1,
"linkText": "Descriptive Text",
"linkTextRaw": "(\u00FE\u00FF\u0000D\u0000e\u0000s\u0000c\u0000r\u0000i\u0000p\u0000t\u0000i\u0000v\u0000e\u0000 \u0000T\u0000e\u0000x\u0000t)",
"targetType": "URI",
"targetValue": "//www.textcontrol.com",
"targetRaw": "(//www.textcontrol.com)",
"source": "Annot window"
},
{
"index": 2,
"linkText": "Descriptive Text",
"linkTextRaw": "(\u00FE\u00FF\u0000D\u0000e\u0000s\u0000c\u0000r\u0000i\u0000p\u0000t\u0000i\u0000v\u0000e\u0000 \u0000T\u0000e\u0000x\u0000t)",
"targetType": "URI",
"targetValue": "//www.textcontrol.com",
"targetRaw": "(//www.textcontrol.com)",
"source": "Annot window"
}
],
"figures": [
{
"index": 1,
"altText": "image in table",
"altRaw": "(\u00FE\u00FF\u0000i\u0000m\u0000a\u0000g\u0000e\u0000 \u0000i\u0000n\u0000 \u0000 \u0000t\u0000a\u0000b\u0000l\u0000e)",
"source": "Figure obj 55"
},
{
"index": 2,
"altText": "Barcode not in table",
"altRaw": "(\u00FE\u00FF\u0000B\u0000a\u0000r\u0000c\u0000o\u0000d\u0000e\u0000 \u0000n\u0000o\u0000t\u0000 \u0000i\u0000n\u0000 \u0000t\u0000a\u0000b\u0000l\u0000e)",
"source": "Figure obj 56"
},
{
"index": 3,
"altText": "Image description",
"altRaw": "(\u00FE\u00FF\u0000I\u0000m\u0000a\u0000g\u0000e\u0000 \u0000d\u0000e\u0000s\u0000c\u0000r\u0000i\u0000p\u0000t\u0000i\u0000o\u0000n)",
"source": "Figure obj 57"
}
],
"forms": [
{
"index": 1,
"fieldName": "list item",
"fieldNameRaw": "(list item)",
"fieldType": "Ch",
"tooltip": "list item",
"tooltipRaw": "(list item)",
"source": "Obj 10"
},
{
"index": 2,
"fieldName": "company_name",
"fieldNameRaw": "(company_name)",
"fieldType": "Tx",
"tooltip": "company_name",
"tooltipRaw": "(company_name)",
"source": "Obj 13"
},
{
"index": 3,
"fieldName": "is_client",
"fieldNameRaw": "(is_client)",
"fieldType": "Btn",
"tooltip": "is_client",
"tooltipRaw": "(is_client)",
"source": "Obj 15"
}
],
"standards": [
{
"standard": "PDF/UA",
"part": "1",
"conformance": null,
"source": "XMP"
},
{
"standard": "PDF/A",
"part": "3",
"conformance": "A",
"source": "XMP"
}
]
}
返回的Report对象提供了对验证结果的结构化访问,使得集成到现有工作流程中变得容易。
即将发布的 TX Text Control 34.0 版本将为开发人员提供强大的工具,使他们能够直接在 .NET 应用程序中创建和验证符合 PDF/UA 和 PDF/A-3a 标准的文档。该验证库简化了确保可访问性和合规性的流程,使开发人员能够自信地满足行业标准。
--------------------------------------------------------------------------
关于慧都
慧都科技是一家行业数字化解决方案公司,长期专注于软件、油气与制造行业。公司基于深入的业务理解与管理洞察,以系统化的业务建模驱动技术落地,帮助企业实现智能化运营与长期竞争优势。在软件工程领域,我们提供开发控件、研发管理、代码开发、部署运维等软件开发全链路所需的产品,提供正版授权采购、技术选型、个性化维保等服务,帮助客户实现技术合规、降本增效与风险可控。慧都科技TX Text Control在中国的合作伙伴,提供TX Text Control系列产品免费试用,咨询,正版销售等于一体的专业化服务。TX Text Control是文档处理与管理领域的优秀产品,帮助企业实现高效的文档开发。
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@ldacury.cn
文章转载自:慧都网