Delete Blank page from End of PDF using Aspose.PDF for .NET

When using pdfkit to put together multiple pdf files into a single one, is there a way to detect if the last page is blank and delete it?

Hi Harry,

Thanks for using our products.

You may try extracting the contents (Text and Image) from last page of the PDF and in case nothing is returned, you can simply use Delete method of
PdfFileEditor class to remove the last page. You may take a look over the following link for information on how to Find whether PDF file contains images or text only

In case you face any problem or you have any further query, please feel free to contact. We apologize for your inconvenience.

@dhhsnc

After obtaining final merged PDF document as output, you can run following code snippet to determine whether the last page is blank or not and delete it.

Detect and Remove Blank (Last) Page from PDF

Document pdfDocument = new Document("FinalMerged.pdf");
bool isBlank = pdfDocument.Pages[pdfDocument.Pages.Count].IsBlank(0.01d);
// Delete a particular page
pdfDocument.Pages.Delete(pdfDocument.Pages.Count);
// Save updated PDF
pdfDocument.Save("output.pdf");

Please use above code snippet with Aspose.PDF for .NET 20.7 and let us know about your feedback.