Is there a way to change the page margins for the second page in a PDF using iTextSharp?
I now have:
Document document = new Document(PageSize.A4, 144f, 72f, 144f, 90f);
PdfWriter.GetInstance(document, ms);
/* first page content */
document.NewPage();
document.SetMargins(72f, 72f, 72f, 100f);
/* second page content */
However, the margins on the second page are the ones set for the first page.
Switch the two lines:
document.SetMargins(72f, 72f, 72f, 100f);
document.NewPage();
As documented, the NewPage() function performs a lot of initialisations, among others, setting the margins. So you need to change the margins BEFORE triggering a new page, not after.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With