Avoid Blank Page in Output PDF when there is Nothing to Print

Possible Usage Scenarios

When the Excel file is empty and the user saves it to PDF using Aspose.Cells, it renders a blank page in the output PDF. Sometimes, this default behavior is undesirable. Aspose.Cells provides the PdfSaveOptions.OutputBlankPageWhenNothingToPrint property to deal with this issue. If you set it to false, then CellsException will occur whenever there is nothing to print in the output PDF.

Avoid Blank Page in Output PDF when there is Nothing to Print

The following sample code creates an empty workbook and then saves it as PDF after setting the PdfSaveOptions.OutputBlankPageWhenNothingToPrint property to false. Since there is nothing to print in the output PDF, the CellsException occurs as shown below.

Sample Code

Exception

  

Aspose.Cells.CellsException was unhandled  

HResult = -2146232832  

Message = There is nothing to output/print.  

Source = Aspose.Cells  

StackTrace:  

   at Aspose.Cells.Workbook.Save(String fileName, SaveOptions saveOptions)