I am facing issue while adding pagebreak to a PDF. I am using Aspose PDF using .Net with version 24.3.0.
Issue : When I add a pagebreak at a particular place in the PDF the margns of the PDF goes away from next page.
See attached PDF and following code.
var pdfDoc = new Document(“\Users\Desktop\ProjectClauseSample.pdf”);
pdfDoc.ProcessParagraphs();
PdfFileEditor fileEditor = new();
MemoryStream streamPageBreak = new();
TextFragmentAbsorber absorber = new(“Project Clauses 2”)
{
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\OutPageBreak.pdf”);
ProjectClauseSample.pdf (145.4 KB)