Java 使用ITextRenderer设置页面的属性

Java 使用ITextRenderer设置页面的属性,java,backbone.js,pdf-generation,mustache,flying-saucer,Java,Backbone.js,Pdf Generation,Mustache,Flying Saucer,我有一个应用程序,可以在某一点导出PDF。问题是我想在PDF的最后一页显示html模板中的某一部分(始终) 我在前端使用主干并编译带有小胡子的html。 以下是exportToPDF方法: public void exportPDF(Petition petition, OutputStream outputStream) { PrintablePetition printablePetition = prepareForPDFExport(petition);

我有一个应用程序,可以在某一点导出PDF。问题是我想在PDF的最后一页显示html模板中的某一部分(始终)

我在前端使用主干并编译带有小胡子的html。 以下是exportToPDF方法:

public void exportPDF(Petition petition, OutputStream outputStream) {
        PrintablePetition printablePetition = prepareForPDFExport(petition);
        MustacheFactory mf = new DefaultMustacheFactory();
        Mustache mustache;
        if (printablePetition.getPetitionType().equals(PetitionTypeEnum.MILK.petitionType())) {
            mustache = mf.compile(TEMPLATE_MILK);
        } else if (printablePetition.getPetitionType().equals(PetitionTypeEnum.FRUITS.petitionType())) {
            mustache = mf.compile(TEMPLATE_FRUIT);
        } else {
            throw new CPERuntimeException(CPEStringUtils.build("Unknown petition type: ", printablePetition.getPetitionType() + ""));
        }
        StringWriter stringWriter = new StringWriter();
        try {
            mustache.execute(stringWriter, new Object[]{printablePetition, new TemplateParams(BASE_URI)}).flush();

            ITextRenderer renderer = new ITextRenderer();
            ITextFontResolver resolver = renderer.getFontResolver();
            resolver.addFont(
                    "fonts" + FILE_SEPARATOR + "arial.ttf",
                    BaseFont.IDENTITY_H,
                    BaseFont.NOT_EMBEDDED
            );
            renderer.setDocumentFromString(stringWriter.toString());
            renderer.layout();
            renderer.createPDF(outputStream);
        } catch (IOException e) {
            LOG.error(e.getMessage(), e);
        } catch (DocumentException e) {
            LOG.error(e.getMessage(), e);
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                LOG.error(e.getMessage(), e);
            }
        }
    }
下面是我想在最后一页显示的html片段:

<section id="last_page">
        <p>
            * - numarul maxim de copii efectiv beneficiari
            N**= 1.03 si intra in calculul cantitatii efectiv furnizate numai in cazul produselor cu unitate de masura in litrii
        </p>

        <br/>
        <br/>

        <table cellspacing="0" width="90%" align="center" style="font-size: 11pt; line-height: 20pt;">
            <tr>
                <td>
                    Întocmit de,<br/>
                    <span style="margin-right: 50pt;">Funcţia ......................</span> <br/>
                    Data _____/_____/_____<br/>
                    Numele, prenumele  şi  semnătura reprezentantului legal al  solicitantului,<br/>
                    ...................................................................................<br/>
                    Data _____/_____/_____
                </td>
                <td style="vertical-align: top;">
                    Ştampila solicitantului
                    <br/>
                </td>
            </tr>
        </table>
    </section>


*-受益人有效性准则
N**=1.03 si在计算中对cazul生产商的furnizate numai或litrii的cu unitate de masura有效



Întocmit de,
Funcţia
数据 Numele,prenumeleşi semnătura reprezentantului法律顾问,

资料_____/_____/_____ Ş坦皮拉酒店
问题是我不知道如何获取该section元素并告诉ITextRenderer始终在最后一页显示它


有什么想法吗?谢谢。

飞碟不是我的礼物。飞碟使用iText。我想添加标签flyingdiscer,但是只允许添加5个标签,所以我用flyingdiscer标签替换了iText标签。如果您想重新引入iText标记,可以随意替换任何其他标记。请注意,飞碟是iText集团不认可(也不支持)的第三方产品。使用它要自担风险(它包含一个完全删除的、不受支持的iText版本)。飞碟不是iText。飞碟使用iText。我想添加标签flyingdiscer,但是只允许添加5个标签,所以我用flyingdiscer标签替换了iText标签。如果您想重新引入iText标记,可以随意替换任何其他标记。请注意,飞碟是iText集团不认可(也不支持)的第三方产品。使用它的风险自负(它包含绝对删除的、不受支持的iText版本)。