This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Different header on first page of pdf than rest of the pages JAVA

anup.a wrote on 2019-11-29:
Team,

I'm using HTML to PDF conversion API. We have a method client.setHtmlHeader(), which sets the same headers to all of the pdf pages.

Is it possible in PDFCrowd to set a different header to the required page (I need it for the first page)?

If not, please let me know if anyone has written any utility etc

Thanks,
Anup
support wrote on 2019-11-29:
I may be achieved by running 2 conversions and join outputs together.
e.g. in C#

pdfcrowd.HtmlToPdfClient client =
new pdfcrowd.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// run 1st page conversion
client.setHeaderHtml("First page header");
client.setPrintPageRange("1");
byte[] pdf1 = client.convertUrl('your-url');

// run the rest pages conversion
client.setHeaderHtml("Different page header");
client.setPrintPageRange("2-");
byte[] pdf2 = client.convertUrl('your-url');

pdfcrowd.PdfToPdfClient merger =
new pdfcrowd.PdfToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

merger.addPdfRawData(pdf1);
merger.addPdfRawData(pdf2);
merger.convertToFile('final.pdf');
anup.a wrote on 2019-11-29:
That was a quick reply and resolved my blocker.

Thanks,
Anup
leapsys wrote on 2020-02-07:
That's a nice way to resolve the extraneous space issue on pages which exclude the header/footer if you don't want that empty space on those pages. But would this technique count as three(3) credits against your license?
support wrote on 2020-02-07:
Yes, this procedure requires 3 conversions because it runs in 3 steps.
support wrote on 2021-03-11:
Our new version supports different header/footer on each page.
Just enable a special CSS annotation by setHeaderFooterCssAnnotation
and use new CSS classes in your header/footer HTML.

See example