Aspose PDF for .NET : Trying to create document that has 1 inch margin on page 1 and 2 inch margin on every other page

I’m currently trying to create a document that has multiple pages where page 1 has margins of (72,72,72,72) and all other pages have margins of (144, 144, 144, 144). I’m setting the PageInfo.Margin property and the PageInfo.AnyMargin property to MarginInfo objects respectively, however the Margin seems to be overriding it. Any help would be appreciated.
Code:

var page = document.Pages.Add();
MarginInfo defaultMargin = new MarginInfo(0, 0, 0, 0);
MarginInfo marginInfo = new(144, 144, 144, 144);
page.PageInfo.Margin = marginInfo;
page.PageInfo.AnyMargin = marginInfo;
document.ProcessParagraphs();

@LDsysadmin

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input PDF.
  • Please attach the output PDF file that shows the undesired behavior.
  • Please attach the expected output PDF file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

example-project.zip (931 Bytes)
multiple-margins.zip (168.5 KB)

it seems like the ‘AnyMargin’ property is being ignored by whatever adds pages when processing the paragraphs. really appreciate the help - this is blocking us. =\

    var DPI = 72;
    var document = new Document();
    // first page should have 0 margins
    document.PageInfo.Margin = new MarginInfo(left: 0 * DPI, right: 0 * DPI, top: 0 * DPI, bottom: 0 * DPI);
    // other pages should have 1 inch margins
    document.PageInfo.AnyMargin = new MarginInfo(left: 1 * DPI, right: 1 * DPI, top: 1 * DPI, bottom: 1 * DPI);
    // add a bunch of nonsense
    var page = document.Pages.Add();
    for (int i = 0; i < 200; i++)
    {
        page.Paragraphs.Add(new HtmlFragment("test line"));
    }
    // push it out to the bin directory
    document.Save("multiple-margins.pdf", new PdfSaveOptions
    {
        DefaultFontName = "Times"
    });

@LDsysadmin

We have logged this problem in our issue tracking system as PDFNET-51921. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.