Free Support Forum - aspose.com

Unable to detect blank pages in PDF document excluding header and footer

static private bool IsBlankPage(Aspose.Pdf.Page page)

{

    if ((page.Contents.Count == 0 && page.Annotations.Count == 0) || HasOnlyWhiteImages(page))

        return true;

    return false;

}

static private bool HasOnlyWhiteImages(Aspose.Pdf.Page page)
{
    // return true if no images exist or all images are white
    if (page.Resources.Images.Count == 0)
    return true;
    foreach (XImage image in page.Resources.Images)
    if (!IsWhiteImage(image))
    return false;
    return true;
}

static private bool IsWhiteImage(XImage image)
{
    MemoryStream ms = new MemoryStream();
    image.Save(ms);
    System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);
    for (int j = 0; j < bmp.Height; j++)
        for (int i = 0; i < bmp.Width; i++)
        {
            System.Drawing.Color color = bmp.GetPixel(i, j);
            if (color.R != 255 || color.G != 255 || color.B != 255)
                return false;
        }
    return true;
}

@saraprak000

Could you please share the sample PDF document as well so that we can test the scenario in our environment and address it accordingly.

Here is the sample document redacted due sensitive information. If you look at page 10 you could see the blank page with header and footer information. Thank you for looking into it.

Sample Document_Aspose.pdf (573.6 KB)

@saraprak000

We were able to replicate the scenario at our side with Aspose.PDF for .NET 20.12 and have logged it as PDFNET-49234 in our issue tracking system for the sake of investigation. We will look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.

Thanks for update. Will looking forward to your rectification.

1 Like

This is to follow up on issue PDFNET-49234 with who ever is working on this issue. Any update would be appreciated. Thank You!

@saraprak000

The ticket has recently been logged in our issue tracking system and will be resolved on a first come first serve basis. We are afraid that it is not yet investigated. We will surely provide an update in this forum thread as soon as we have some regarding fix of the issue. Please give us some time.

We apologize for the inconvenience.