We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Document.Pages.Clear clears page properties

Hello,

I have a use case where I am creating different pages for PDF. At the end I consolidate and put in my preferred order. To achieve this I need to clear Document object and add the pages again. But now it loses all page properties. I have written a sample code here. Please advise.

var pdfDocument = new Document();
pdfDocument.PageInfo.DefaultTextState = new TextState()
{
Font = FontRepository.FindFont(DefaultFont)
};

        var sec = pdfDocument.Pages.Add();

        PageSize pageSize = PageSize.A0;
        sec.SetPageSize(pageSize.Width, pageSize.Height);
        sec.PageInfo.Margin = new MarginInfo(36, 36, 36, 36);
        var floatingBox = new FloatingBox()
        {
            Border = new BorderInfo(BorderSide.All, 12),
            BackgroundColor = Color.Pink,
            Height = pageSize.Height - sec.PageInfo.Margin.Bottom - sec.PageInfo.Margin.Top,
            Width = pageSize.Width - sec.PageInfo.Margin.Left - sec.PageInfo.Margin.Right

        };
        sec.Paragraphs.Add(floatingBox);

        // Compose sections into single document
        pdfDocument.Pages.Clear();
        pdfDocument.Pages.Add(sec);
        
        var modifiedFileName = "c://Abc.pdf";
        // Save to byte array
        pdfDocument.Save(modifiedFileName);

You can see the difference in PDF by commenting clear and add line, and checking the output

@sgarg.saba

We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as PDFNET-51229. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Can you share timeline for resolution, as it will be blocker for us in our efforts to move to new DOM

@sgarg.saba

Currently, your issue is pending for analysis and is in the queue. Once we complete the analysis of your issue, we will then be able to provide you an estimate.

Is there any update on this.

@sgarg.saba

Unfortunately, there is no update available on your issue at the moment. We will be sure to inform you via this forum thread once there is any update available on it.