2010-08-11 64 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();