Dynamically Adjust Margin per Page

Hello
After a Document has been created, is there a way to adjust margins of specific pages, rather than the entire document?

We are using the most recent version of Aspose.PDF, and we are generating our PDFs from HTML.

Attached you will find a console application that produces 2 PDFs.

The 1st PDF shows the actual behavior that is happening when we try to alter the page margins AFTER the document has been created.

The 2nd PDF shows our desired outcome. You can see in this PDF that there are more pages than the first because the margins of the 2nd and 3rd page are higher than the margins on the 1st page.

I am attaching console application for both scenarios.

Let me know if you need any additional information.
ConsoleApp_Update_Margins 2.zip (144.0 KB)

Thanks

@ANDREA.FARRIS

Can you please provide more details about how you are currently attempting to adjust the margins for specific pages in your PDF document?

They are provided in console application attached with ticket.

//Scenario 1
// Create a document with a default top-margin
Document pdfDocument = new Document(htmlInputPath, htmlLoadOptions);

// Update top margin to page number 2 doesn’t work
foreach (var page in pdfDocument.Pages.Skip(1))
{
page.PageInfo.Margin.Top = 200;
}

pdfDocument.Save(“output_scenario_1.pdf”);

//Scenario 2
Document pdfDocument1 = new Document(htmlInputPath, htmlLoadOptions);

// Create a document with updated top-margin
htmlLoadOptions.PageInfo.Margin.Top = 200;
Document pdfDocument2 = new Document(htmlInputPath, htmlLoadOptions);

// Create the final document
Document mergedPdfDocument = new Document();

// Merge documents into the final document
mergedPdfDocument.Pages.Add(pdfDocument1.Pages[1]);
foreach (var pagePdfDocument2 in pdfDocument2.Pages.Skip(1))
{
mergedPdfDocument.Pages.Add(pagePdfDocument2);
}

mergedPdfDocument.Save(“output_scenario_2.pdf”);

Thanks

@ANDREA.FARRIS

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-58951

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.