我使用 iText 5.2.1 并且我已经创建了 Document 对象。
像这样:
document.addHeader("hello");
为什么我在 PDF 文件上看不到标题?
使用页面事件。StackOverflow 上已经提供了许多好的答案,例如this one或this other one。
try {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("FicheClient.pdf"));
document.open();
document.add(new Paragraph("hello World",FontFactory.getFont(FontFactory.TIMES_BOLD,20,Font.BOLD,BaseColor.BLACK)));
document.add(new Paragraph("---------------------------------------"));
document.close();
JOptionPane.showMessageDialog(null, "Raport saved ");
} catch (Exception e) {
}