它有点用于寻找新页面的问题.我pdfContentByte使用下面的代码将第一页之后的数据放到下一页但不幸的iText是没有生成新的页面.
//step1
itextDocument = new com.itextpdf.text.Document(PageSize.A4, 50, 50, 30, 65);
writer = PdfWriter.getInstance(itextDocument, new FileOutputStream(RESULT));
itextDocument.open();
writer.setPageEmpty(true);
itextDocument.newPage();
// step 2 == design and set the postions
// Measuring a String in Helvetica
Font font = new Font(FontFamily.TIMES_ROMAN, 10);
BaseFont romanFont = font.getCalculatedBaseFont(false);
// Drawing lines to see where the text is added
PdfContentByte canvas = writer.getDirectContent();
canvas.saveState();
canvas.stroke();
canvas.restoreState();
// Adding text with PdfContentByte.showTextAligned()
canvas.beginText();
canvas.setFontAndSize(romanFont, 10);
//=================== get data from xml and put in …Run Code Online (Sandbox Code Playgroud)