2010-08-11 47 views
0

我正在使用Java,我想知道如何在PDF文件中做一个分页符?在50行之后,我想开始在新页面上书写。java pdf文件写

我正在使用iText库。

+0

您正在使用哪一个pdf库? – naikus 2010-08-11 10:46:14

回答

4

可以使用iText库创建一个PDF Java


Document document = new Document(); 
try { 
PdfWriter.getInstance(document, 
new FileOutputStream("HelloWorld.pdf")); 
document.open(); 
document.add(
new Paragraph("Hello World")); 
document.newpage(); 

// You are on the new page from here. 
// Note that newpage method won't work on empty pages, 
// so first you should add something to previous page and then call this method 
// to create new page 

} catch (Exception e) { 
// handle exception 
} 
document.close();