How to add header in iText 5.2.1?

2019-07-04 03:16发布

问题:

I use iText 5.2.1 and I have already created Document object.

like this:

document.addHeader("hello");

Why don't I see the header on the PDF File?

回答1:

Use Page Events. Many good answers have been provided already on StackOverflow, for example this one, or this other one.



回答2:

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


标签: java itext