I tried to add custom header and footer for my exported pdf. I added preProcessPdf and tried to add header for the document:
Code: Select all
public void preProcessPDF(Object document) throws DocumentException {
Document pdf = (Document)document;
HeaderFooter header = new HeaderFooter(Phrase.getInstance(getHeader()), true);
pdf.setHeader(header);
HeaderFooter footer = new HeaderFooter(new Phrase("This is page "), new Phrase("."));
pdf.setFooter(footer);
}
From the doc of com.lowagie.text.Document.open:
Could there be added "onBeforeOpen" event for dataexporter? Or does some have a trick how to get header for the first page?Opens the document.
Once the document is opened, you can't write any Header- or Meta-information anymore. You have to open the document before you can begin to add content to the body of the document.