我是iText的新手。我想用iText(Java)以PDF格式創建幾個報告。每一份報告都將採用不同的設計。有沒有辦法手動創建模板?我正在使用數據庫數據來創建PDF。 iText有什麼功能可以讓我做到這一點。提前致謝。使用iText和java創建PDF的自定義模板
1
A
回答
3
如果您打算使用另一個pdf作爲模板並將其作爲背景,您可以按照以下方式進行操作。
//Starting a new pdf document
Document document = new Document();
ByteArrayOutputStream os = new ByteArrayOutputStream();
//This is your new pdf doc
PdfWriter writer = PdfWriter.getInstance(document, os);
document.open();
document.newPage();
//Get the file of you template, you should use try catch and then close it
//I simply to just show sistem
FileInputStream template = new FileInputStream("template.pdf");
//Load it into a reader
PdfReader reader = new PdfReader(template);
//Get the page of the template you like
PdfImportedPage page = writer.getImportedPage(reader, 1);
//Now you can add it to you report
PdfContentByte cb = writer.getDirectContent();
cb.addTemplate(page, 0, 0);
//Here goes code of other stuff that you add..
+0
我有疑問..template.pdf會讓我的設計成爲禮儀嗎? –
+0
正確的,它將成爲你創建PDF的背景,有metods以及提取另一個pdf的一部分,並使用這個作爲模板作爲組件(例如reapeating部分),在您創建的pdf –
+0
簽出這個例子http ://itextpdf.com/examples/iia.php?id=73 –
相關問題
- 1. 使用iTEXT創建Java PDF
- 2. 使用iText創建PDF
- 3. 無法使用iText和JSF創建PDF
- 4. 在JAVA中使用Apache POI和iText創建Word(DOC)中的PDF
- 5. Java使用iText製作自定義報告PDF
- 6. 使用自定義值創建PDF
- 7. java itext使用希伯來語(rtl)和英語創建pdf
- 8. 使用自定義屬性和模板創建角度指令
- 9. 使用itext創建pdf的問題
- 10. zip使用itext創建的pdf文件
- 11. JavaFX - IText - 創建PDF時創建PDF
- 12. 使現有的PDF進入模板 - iText
- 13. 使用iText和java的PDF生成器
- 14. 的Android iText的PDF創建
- 15. itext java pdf到文本創建
- 16. 自定義GUI模板腳本創建
- 17. XCode 4.2自定義模板創建?
- 18. 創建自定義頁面模板
- 19. Datagrip,創建自定義模板
- 20. 創建自定義Xcode項目模板?
- 21. 爲SharePoint創建自定義ItemStyle模板
- 22. 爲KendoUI創建自定義模板ListView
- 23. 使用iText從TIFF圖像創建PDF
- 24. 使用Spring,IText,水印創建PDF
- 25. 使用IText創建PDF文檔#
- 26. 如何導出使用pdf模板和itext的數據集?
- 27. 使用Debenu Quick PDF創建自定義大小的PDF文檔
- 28. Itext使用Java創建PDF格式的XMP
- 29. Drupal 7使用面板模塊創建的自定義佈局
- 30. 使用模板創建PDF文件
考慮使用jasper報告,然後導出到pdf。這個報告系統有一個圖形界面iReport –
我的要求是使用iText。 –