如何用Ghostscript从PostScript文件生成符合PDF/UA标准的可访问PDF
生成符合PDF/UA标准的可访问PDF(Ghostscript实现问题)
我用Ghostscript将PostScript文件转换为PDF,从六月起需要生成符合PDF/UA标准的可访问PDF。相关资料只提供了文档和ISO-14289标准链接,没有明确标签的具体实现方法。
尝试的最小PS示例
我按照建议在PostScript中添加了用于内容标记的pdfmarks,代码如下:
%!PS-Adobe-3.0 %%Title: Minimal Tagged PDF %%Creator: Tagged PS Test %%Pages: 1 %%LanguageLevel: 2 %%EndComments /Times-Roman findfont 12 scalefont setfont %%Page: 1 1 % Optional metadata [ /Title (Minimal Tagged PDF) /Author (Your Name) /Subject (Testing Tagged PDFs with Ghostscript) /DOCINFO pdfmark % Enable tagging mode [ {Catalog} << /MarkInfo << /Marked true >> >> /PUT pdfmark % Define Resources dictionary with structure tags /R1 << /Type /StructElem /S /Document /K [ << /Type /StructElem /S /H /P 0 /K [ << /MCID 0 >> ] >> % H1 Tag << /Type /StructElem /S /P /P 1 /K [ << /MCID 1 >> ] >> % Paragraph Tag ] >> % End of Resources % The /R1 dictionary connects these tags to the page resources % Tagged content: heading 0 750 moveto [ /H1 << /MCID 0 >> /BDC pdfmark (Hello, accessible world!) show [ /EMC pdfmark % Tagged content: paragraph 0 730 moveto [ /P << /MCID 1 >> /BDC pdfmark (This is a minimal tagged content using Ghostscript. No tree, but tags are visible.) show [ /EMC pdfmark showpage %%EOF
编译后PDF中的标签内容
生成的PDF包含以下标签内容:
/H1/R4 BDC 0 g q 10 0 0 10 0 0 cm BT /R7 12 Tf 1 0 0 1 0 750 Tm (Hello, accessible world!)Tj ET Q EMC /P/R8 BDC q 10 0 0 10 0 0 cm BT /R7 12 Tf 1 0 0 1 0 730 Tm (This is a minimal tagged content using Ghostscript. No tree, but tags are visible.)Tj ET Q EMC
但在Adobe Acrobat中打开时看不到标签,推测问题出在缺失StructTree。我想知道Ghostscript生成的PDF是否能包含StructTree?Adobe Distiller的相关文档不适用于Ghostscript,而Ghostscript官方文档也没提到StructTree的实现方法。
失败的StructTreeRoot尝试
我尝试添加以下代码引入StructTree,但无法编译:
[ /StructTreeRoot << /Type /StructTreeRoot /K [ << /Type /StructElem /S /H1 /K [0] >> << /Type /StructElem /S /P /K [1] >> ] >> /StructTreeRoot /PUT pdfmark
需求目标
我希望实现以下两种方案之一:
- 生成带有标签但无StructTree的PDF/UA;
- 不通过StPNE直接引入StructTree。
注:因许可问题无法切换到Adobe Distiller,因性能问题无法使用LaTeX,也难以对成品PDF进行后处理自动生成标签。
内容的提问来源于stack exchange,提问作者Puzzled Goblin
相关产品推荐
相关产品推荐

