IronPdf Add text to end of the page inserts new page

1k Views Asked by At

i'm trying to manipulate pdf and i tried some of opensource libraries (e.g pdfSharp, pdfjet) and i cannot achive what i must do. Because pdfsharp add it with a new page to pdf, or pdfjet put an advert into pdf. So, i cannot use those libraries.

What i must achive is:

i must put a string at the end of the last page of pdf. If last page have enough space to put the string, then there is no need to add a new page, otherwise, string can be splitted or add a new page to pdf.

Here is a code sample i tried;

HtmlToPdf renderer = new IronPdf.HtmlToPdf();
IronPdf.PdfDocument doc = IronPdf.PdfDocument.FromFile(existingPdfPath);
doc.AppendPdf(renderer.RenderHtmlAsPdf(stringAddToPdf));
doc.SaveAs(newPdfPath);

Thanks for helps,

1

There are 1 best solutions below

1
Matthew On

From what I can understand, AppendPdf is actually designed to always insert a new page..

https://ironpdf.com/c%23-pdf-documentation/html/M_IronPdf_PdfDocument_AppendPdf.htm

My suggestion would be to add the string as a footer as this should be possible either with AddHeaders/AddFooters/AddHTMLHeaders/AddHTMLFooters

https://ironpdf.com/c%23-pdf-documentation/html/Methods_T_IronPdf_PdfDocument.htm