在Seam iText中创建标记的PDF文档

时间:2013-03-13 18:19:00

标签: pdf itext accessibility seam

我正在尝试使用Seam及其accessible PDF创建iText implementation。我找不到任何关于这是否可行的参考。似乎iText本身可以处理它; this example上的PDF已被标记。但是我们创建的所有PDF都没有,我似乎无法弄清楚如何添加它。

以下是我们的一份文件中的一些示例代码:

<?xml version="1.0" encoding="UTF-8"?>
<p:document xmlns:p="http://jboss.com/products/seam/pdf" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:h="http://java.sun.com/jsf/html" type="PDF" pageSize="letter" title="Letter" margins="15.0 40.0 20.0 10.0">


    <f:facet name="header">
        <p:font size="10" name="TIMES-ROMAN" style="bold">
            <p:header borderWidth="0"/>
            <p:footer borderWidthTop="0" borderWidthBottom="0" alignment="center">
FY #{handler.form.year}<p:text value=" #{handler.form.name}"/><p:text value="     "/>CAN #{handler.form.number}<p:text value="     "/>Object Class #{handler.form.class}<p:text value="     "/>#{handler.form.time} 
            </p:footer>
        </p:font>
    </f:facet>

    <p:font size="10" name="TIMES-ROMAN">
        <p:table columns="3" widthPercentage="100" widths="1 2 1">
        <p:cell borderWidth="0">
                <p:image alignment="left" value="/assets/img/logo.PNG" scalePercent="5"/>
        </p:cell>
        <p:cell borderWidth="0" horizontalAlignment="center" paddingTop="30">
            <p:paragraph>

                WORKSHEET
            </p:paragraph>
        </p:cell>
... snip ...

我意识到这不是最好的代码(我只是从我需要清理的文档中提取)。关于Seam是否可以实际放入PDF标签的任何想法?

1 个答案:

答案 0 :(得分:3)

自iText 5.4.0(这是最新版本)以来,支持开箱即用的标记PDF。

当你使用Paragraph,PdfPTable等高级对象时,你使用PdfWriter.setTagged(),那么你就可以得到质量好的Tagged PDF。你甚至可以选择自己的角色。

如果jBoss / SEAM将使用这样一个最新版本的iText,我会感到惊讶。我已经联系他们进行升级,SEAM团队从未做出回应。 (我是谁?我是iText Software的首席执行官。)