I am using Aspose PDF with version 24.3.0 and processing the html to pdf. I am setting some margin at top for every page while PDF creation.
I am applying a page break at page 6, my content is successfully moved to page 7,
but margin which I have set is not applied moreover, some content on page 7 is moved to page 8 while there is still space left on page 7.
Here is my sample code:
var pdfDoc = new Document(“\Users\Desktop\1596_1.pdf”);
pdfDoc.ProcessParagraphs();
PdfFileEditor fileEditor = new();
MemoryStream streamPageBreak = new();
TextFragmentAbsorber absorber = new(“Section PDF 3”)
{
TextSearchOptions = new TextSearchOptions(true)
};
pdfDoc.Pages.Accept(absorber);
TextFragment textFragment = absorber.TextFragments[1];
fileEditor.AddPageBreak(memory, streamPageBreak, new PdfFileEditor.PageBreak[]
{
new PdfFileEditor.PageBreak(textFragment.Page.Number, textFragment.Rectangle.URY - 1)
});
pdfDoc = new Document(streamPageBreak);
pdfDoc.Save(“\Users\Desktop\P5.pdf”);