Aspose.Cell convert to pdf without blank pages

I want to hide the blank page when I convert excel file to pdf but it doesn’t work

Stream oStreamGiris = new MemoryStream(baryIcerik);
Aspose.Cells.Workbook oWorkbook = new Aspose.Cells.Workbook(oStreamGiris);
oStreamGiris.Close();

using (MemoryStream oStreamCikis = new MemoryStream())
{
Aspose.Cells.PdfSaveOptions oPdfSaveOptions = new Aspose.Cells.PdfSaveOptions();
oPdfSaveOptions.OutputBlankPageWhenNothingToPrint = false;
oPdfSaveOptions.OnePagePerSheet = OnePagePerSheet;
oWorkbook.Save(oStreamCikis, oPdfSaveOptions);
return oStreamCikis.ToArray();
}

@Habib_S

To prevent blank pages when converting an Excel file to PDF using Aspose.Cells, you need to ensure that the OutputBlankPageWhenNothingToPrint property is set to false. This property controls whether a blank page is generated when there is no content to print.

Here’s a code snippet that demonstrates how to set this property correctly:

using System;
using System.IO;
using Aspose.Cells;

public class ConvertExcelToPdf
{
    public static byte[] ConvertToPdf(byte[] baryIcerik, bool OnePagePerSheet)
    {
        using (MemoryStream oStreamGiris = new MemoryStream(baryIcerik))
        {
            Workbook oWorkbook = new Workbook(oStreamGiris);
            oStreamGiris.Close();

            using (MemoryStream oStreamCikis = new MemoryStream())
            {
                PdfSaveOptions oPdfSaveOptions = new PdfSaveOptions
                {
                    OutputBlankPageWhenNothingToPrint = false, // Prevent blank pages
                    OnePagePerSheet = OnePagePerSheet
                };
                oWorkbook.Save(oStreamCikis, oPdfSaveOptions);
                return oStreamCikis.ToArray();
            }
        }
    }
}

In this example, the OutputBlankPageWhenNothingToPrint property is explicitly set to false, which instructs Aspose.Cells not to generate a blank page if there is no content in the workbook. If the workbook is empty, an exception will be thrown, indicating that there is nothing to print, which is the expected behavior when this property is set to false [1][2].

Make sure to handle any exceptions that may arise when saving the workbook, especially if it is empty.

For further details, you can refer to the documentation on avoiding blank pages in PDF outputs when using Aspose.Cells [1].

Sources:
[1]: Avoid Blank Page in Output PDF when there is Nothing to Print
[2]: Output Blank Page when there is Nothing to Print|Documentation

i use this option
my file is
(rar file format)
02SUBAT2025MobilDeskListesi.7z (673.3 KB)

@Habib_S
Please try the following codes:

 PdfSaveOptions saveOptions = new PdfSaveOptions();
//ignore blank pages
 saveOptions.PrintingPageType = PrintingPageType.IgnoreBlank;
//ignore pages which are blank or only contains style
// saveOptions.PrintingPageType = PrintingPageType.IgnoreStyle;
 workbook.Save(dir + "dest.pdf", saveOptions);