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