2012-06-20 74 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) { 
    }