开发者

Java iText Footer

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 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(footer) should be called before opening the document

Corrected code as follows

HeaderFooter footer = new HeaderFooter(new Phrase("This is page "), true);
document.setFooter(footer);

// Document should open after setting the footer
document.open();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜