本文介绍了Java iText页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用JSP页面和我的编码大纲生成PDF,如下所示:
I’m trying to generate a PDF using a JSP page and my coding outline as follows,
Document document = new Document(PageSize.A4,70/*Left*/,70/*Right*/,140/*Top*/,30/*Bottom*/);
response.setContentType("application/pdf" );
response.setHeader("Content-Disposition","inline; filename=vishwa-mandate.pdf");
PdfWriter.getInstance(document, response.getOutputStream());
document.open();
HeaderFooter footer = new HeaderFooter(new Phrase("This is page "), true);
document.setFooter(footer);
/* PAGE 01 */
document.newPage();
/* PAGE 02 + */
document.close();
一旦我明确调用文档,页脚就不适用于PAGE 01。 newPage();
如何在整个文档中获取页脚?
Page footer doesn’t apply to PAGE 01 once I explicitly call document.newPage();
How can I get the footer though out the whole document?
推荐答案
应在打开文档前调用setFooter(页脚)
setFooter(footer) should be called before opening the document
更正后的代码如下
HeaderFooter footer = new HeaderFooter(new Phrase("This is page "), true);
document.setFooter(footer);
// Document should open after setting the footer
document.open();
这篇关于Java iText页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!