I’ve been working with ITextSharp and using it to generate PDFs – however I recently encountered an issue where the top margin of all pages beyond the first seem to be ignored and as a result writing occurs over my header.
Current margins:
document.SetMargins(72,72, 36, 36);
It should be noted that the left and right margins work perfectly beyond the first page – however it seems to ignore the top margin and begin the text at the top of the page (where the header occurs).
Does anyone have any insights as to why this might occur? Or is there an area or event that I could use to reinforce the document margins for each page? (Perhaps the OnStartPage event?)
I would be glad to provide any additional code if needed – as I know that ITextSharp can become very convoluted code-wise.
Resolved the issue as per Alexis Pigeon’s instructions of including the Header and Footers into the
OnEndPageevent as opposed to each of them being in a separate event. I also adjusted the margins (increasing the bottom margin) to prevent the overwriting.