I'm using iText and pdfHtml to convert HTML pages to PDF.
Though I'm having trouble getting each page to adjust to it's specific header or footer.
Some of the headers / footers I'm using are taller than others, thus the content needs to start further down.
To get the headers / footers onto the page I'm using an event handler that generates a PdfXObject
for each required header / footer and pastes it onto the page using a PdfCanvas
.
However, since the headers and footers are not really part of the page content, iText doesn't know how much space they require.
It seems that you can only set the page margins once. Either by using the @page
rule and HtmlConverter.convertToPdf()
or by using Document.setMargins()
when using HtmlConverter.convertToElements()
. You can technically specify one more specific margin for the first page using @page:first
, but that's not really all that useful if page 2 uses a different header than page 3.
Is there any way of adjusting the page margins to the header / footer of each individual page?
Also, maybe pasting them onto the finished page isn't the best practice either, please do tell me if so.
Cheers
--Zuzu_Typ--