page.IsBlank(0.01) Reports a page as blank when it is not

I have tried this in 17.10 and Demo 18.8. Both versions think the page is blank when in fact it is not. I have tried the following for the “BlankPageDetectionTolerance” 0.01, 0.05, 1.0, 2.0, 4.0 No change in the outcome. I have not had any luck in using page.Annotations.Count, page.Contents.Count, or page.Resources.Images.Count, because on pages that are accually blank, I get a count of 1 image and two items in the Contents. Here is how I am using it. Any help would be greatly appreciated. I would share my document but do not have a way to post a file on here.

Thanks John

private void RemoveBlankPageBasedOnMode(string filePath, RemoveBlankPageMode mode)
{
var NewDocument = new Aspose.Pdf.Document();
bool AddPage = true;

using (var pdfDocument = new Aspose.Pdf.Document(filePath))
{
	PageCollection allPages = pdfDocument.Pages;
	foreach (Page page in pdfDocument.Pages)
	{
		AddPage = true;
		page.Flatten();

		// Is the page blank?
		if (page.IsBlank(BlankPageDetectionTolerance)) 
		{
			// What Mode are we in?
			if (mode == RemoveBlankPageMode.Remove_Second_Page)
			{
				if (page.Number == 2) // This is the back side of the cover page if in duplex mode.
				{
					AddPage = false;
				}
			}
			else if (mode == RemoveBlankPageMode.Remove_All)
			{
				AddPage = false;
			}
			else
			{
				_logger.Error("Given Remove Blank Page Mode not recognized. ");
			}
		}

		// Add or Exclude the page from the document
		if (AddPage)
		{
			NewDocument.Pages.Add(page);
		}
	}
}
//  Save file HERE ! ! !
NewDocument.Save(filePath);

}

Test File 4 pages.pdf (105.9 KB)

Here is the test file and the code will try to remove page two.

@jmisuraca

Thanks for contacting support.

Please use following code snippet to detect blank pages inside PDF with latest version of the API i.e. Aspose.PDF for .NET 18.8

string inputFileName = dataDir + @"Test File 4 pages.pdf";
Document pdfDocument = new Document(inputFileName);
bool isBlank = pdfDocument.Pages[2].IsBlank(0.01d); 

We also have tested the code snippet with your PDF and result was fine. It detected second page as blank.

But that is the problem. Page 2 is not blank, I feel the result of the call IsBlank is inaccurately reporting the status of page two. I have uploaded a picture of page to so you can see it is not blank. Specifically when dealing with the “Test File 4 Pages.pdf”, the only page that should be detected as blank is page 4.

Picture of page 2.png (31.2 KB)

I refactored to use a for loop.

Aspose.Pdf.Document OutDocument = new Aspose.Pdf.Document();
bool AddPage = true;

using (Aspose.Pdf.Document InputDocument = new Aspose.Pdf.Document(filePath))
{
	// Check each page!
	for (int i = 1; i < InputDocument.Pages.Count; i++)
	{
		AddPage = true;
		// Is it Blank?
		if (InputDocument.Pages[i].IsBlank(0.01d))
		{
			// What Mode are we in?
			if (mode == RemoveBlankPageMode.Remove_Second_Page)
			{
				if (InputDocument.Pages[i].Number == 2) // This is the back side of the cover page if in duplex mode.
				{
					AddPage = false;
				}
			}
			else if (mode == RemoveBlankPageMode.Remove_All)
			{
				AddPage = false;
			}
			else
			{
				_logger.Error("Given Remove Blank Page Mode not recognized. ");
			}
		}
		if (AddPage)
		{
			OutDocument.Pages.Add(InputDocument.Pages[i]);
		}
	}
}
	
//  Save file HERE ! ! !
OutDocument.Save(filePath);

@jmisuraca

We apologize for the misunderstanding. We were able to notice the issue and logged it as PDFNET-45291 in our issue tracking system. We will further investigate it and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Hi Asad,

I was wondering if this was reviewed and considered for a future release? If there will be a fix in the future I can let my customer know its coming, and everything is good. If you will not fix, then I must start to look for other solutions.

Thank you for you time and effort.
John.

@jmisuraca

Please note that we investigate and resolve every logged issue reported by our customers. However, in free support model, issues are investigated/resolved on first come first serve basis and have low priority. I regret to share that we may not be able to share any reliable ETA as there is already a long queue of previously reported issues.

We also offer paid support option where our customers report their urgent issues and they get resolved on priority basis. You can please check it if your issue is a blocker. As soon as we have some further updates regarding resolution of your issue, we will surely inform you. Please be patient and spare us little time.

We are sorry for the inconvenience.

Hi Asad,

I am happy to report that we (nQueue) have re-newed our license with Aspose and we have also paid for “paid support” Please elevate this issue to Paid Support.

If you need any private information please email me at jmisuraca@nqueue.com and I can forward your request for information to the appropriate internal personal.

Thank you
John

@jmisuraca

Thanks for writing back.

We would like to request you to please create a post over paid support forums (http://helpdesk.aspose.com/) with the reference of issue ID. Your issue will definitely be escalated accordingly. You may login to helpdesk using same email address used for subscription.

The issues you have found earlier (filed as PDFNET-45291) have been fixed in Aspose.PDF for .NET 18.11.