This is continuation of the previous question. (Removing Empty Pages in a PDF document using C#) Many thanks for all the help.
Im trying to remove random empty pages from a PDF document which has more than 500 pages. With the help of previous question answers, I thought of iterate through the whole PDF page by page, scan the content and if content is empty remove the empty page.
Now, Im trying to identify the emptiness of the page like shown below. But, below code does not work as pdfPage.ClientRectangle.IsEmpty returns false for empty pages as well.
for (int i = 0; i < completePdf.Pages.Count; i++)
{
PdfPage pdfPage = completePdf.Pages[i];
bool isEmpty = false;
if (completePdf.Pages[i] != null)
{
isEmpty = pdfPage.ClientRectangle.IsEmpty; // this gives false to empty/blank page
}
// page removal logic
if (isEmpty)
{
// RemoveAt method usage - http://selectpdf.com/docs/M_SelectPdf_PdfDocument_RemovePageAt.htm
}
}
Any help will be much appreciated and thanks in advance.