使用itext在pdf中不显示JSF输出文本值

时间:2016-03-31 12:50:07

标签: jsf itext

我尝试使用itext将xhtml导出为pdf,并且我将值从第一页传递到第二页并且我试图打印第二页我的问题是从第一页传递的outputtext值显示在第二页但是当我生成pdf时静态文本在那里,但我插入的值不存在 这是第一页inputtext

<h:inputText id="username" value="#{PrintController.name}" ></h:inputText>

这是第二页

<h:outputText value="#{PrintController.name}" />

这是使用

的命令按钮
    <h:commandButton value="Create PDF" action="#{PrintController.create}">
    <f:param name="action" value="http://localhost:8080/test/more.xhtml" />
    </h:commandButton>

这是打印方法

try {
        final ITextRenderer iTextRenderer = new ITextRenderer();

        iTextRenderer.setDocument(url);
        iTextRenderer.layout();
        File file=new File("C:/files/invoice.pdf");

        final FileOutputStream fileOutputStream = 
                    new FileOutputStream(file);


        iTextRenderer.createPDF(fileOutputStream);
        fileOutputStream.close();
        Faces.sendFile(file, true);
    } catch (final DocumentException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

生成的pdf没有显示outputText的值,但是它显示在第二页中,我改为pdf

0 个答案:

没有答案
相关问题