2012-06-20 72 views
3

我使用iText 5.2.1,并且我已经创建了Document对象。如何在iText 5.2.1中添加标题?

这样的:

document.addHeader("hello"); 

为什么我没有看到在PDF文件中的标题?

+0

可能重复的[添加标题,利用iText PDF](http://stackoverflow.com/questions/5062898/add-header-to-pdf-using-itext) – sloth

回答

2

使用页面事件。 StackOverflow已经提供了许多很好的答案,例如this onethis other one。的

+0

你的回答是要很大的帮助我感谢你。 – Rancho

-1
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) { 
    }