How can we identify Blank page while generate tiff of Word, Excel And PPT

How can we identify Blank pages while generating tiff of Word, Excel, And PPT
My target is if I found a blank page then not generate a tiff of it.

@hemalp,

For rendering TIFF image while excluding blank pages from Excel spreadsheet using Aspose.Cells APIs, please try the following sample code for your reference:
e.g.
Sample code:

Workbook workbook= new Workbook("g:\\test2\\Bk_blankpages1.xlsx");
ImageOrPrintOptions tiffOptions = new ImageOrPrintOptions();
tiffOptions.HorizontalResolution = 300;
tiffOptions.VerticalResolution = 300;
tiffOptions.PrintingPage = PrintingPageType.IgnoreBlank;
tiffOptions.ImageType = ImageType.Tiff;
tiffOptions.TiffCompression = TiffCompression.CompressionLZW;
        
WorkbookRender workbookRender = new WorkbookRender(workbook, tiffOptions);
workbookRender.ToImage("g:\\test2\\out1.tiff");

The output TIFF image file would not contain blank pages in it.

I hope this helps you a bit.

Is this functionality is available for PPT and Word

@hemalp,

My colleagues from Aspose.Words and Aspose.Slides teams will reply you perspective to the APIs soon.

@hemalp Word documents are not fixed page formats, they are flow, more like HTML. So, there is no easy way to determine where page starts or ends and no easy way to determine whether some particular page is blank. However, there are few options to set an explicit page break in Word document. For example,

If you delete such explicit page breaks from your document, this might help you to get rid blank pages.

Also, Aspose.Words has a method Document.ExtractPages. Using this method you can extract page by page from the document, check whether it is blank and then combine not blank pages back. But in this case each page will be represented as a separate section in the resulting document.

@hemalp,
Unfortunately, Aspose.Slides does not have such an option in the TiffOptions class.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESNET-43917

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

As a workaround, you can try checking if a slide contains content.

@hemalp,
Our developers have considered your requirements. Using Aspose.Slides, the following solution works fine if the “blank page” means a slide without any shape:

using (var presentation = new Presentation("example.pptx"))
{
    using (var clonedPresentation = new Presentation())
    {
        clonedPresentation.Slides.RemoveAt(0);
        clonedPresentation.Masters.RemoveAt(0);

        foreach (ISlide slide in presentation.Slides)
        {
            // Clone every non-blank slide.
            if (slide.Shapes.Count > 0) 
            {
                clonedPresentation.Slides.AddClone(slide); 
            }
        }

        clonedPresentation.Save("output.tiff", SaveFormat.Tiff);
    }
}

Documents: Clone Slides

@amjad.sahi
It will work, but by using PrintingPageType.IgnoreBlank Property Blank tiff will automatically remove. but I cannot Identify Which tiff is blank, So can you suggest any method which can Identify The Blank page

@hemalp,

You can use WorkbookPrintingPreview and SheetPrintingPreview classes to get number of pages if a workbook or specific worksheet has, see the document with example code for your reference. To check if a worksheet is blank or empty, you have to check the Cells.MaxDataRow or Cells.MaxDataColumn properties. If the aforementioned properties return zero or positive values that means, one or more cells have been populated, however, if any of these properties return -1 that indicates that none of the cells have been populated in the given worksheet. See the document on detecting empty worksheets with example code for your reference.