How to change margin for second page in PDF using iTextsharp?

Is there a way to change the page margins for the second page in a PDF using iTextSharp?

Now I 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 fields on the second page are those that are set for the first page.

+4
source share
1 answer

Toggle two lines:

 document.SetMargins(72f, 72f, 72f, 100f); document.NewPage(); 

As described in the document, the NewPage () function performs many initializations, among others, sets fields. Therefore, you need to change the fields before starting a new page, not after.

+12
source

Source: https://habr.com/ru/post/1432963/


All Articles