Free Support Forum -

The footer page number in the multi sheets workbook


The footer page number in the multi sheets workbook is different converting JPEG/PDF.
The PDF file can be outputted the page number of the 3rd and 4th. the total page number is 4.
But Jpeg files are outputted page number of each sheet.
Can I output the total page number and page number in workbook like PDF file?

I have attached the original Excel file and converted PDF file and Jpeg Images. (121.4 KB)

This is my code.

public static List ConvertExcelToImage(string docName, MemoryStream docStream, Dictionary<string, string> config)
		var pageInfoList = new List();

        // Get config setting
        string docRootDir = config["DocumentsFilePath"];
        int dpi = int.Parse(config["ImageDPI"]);
        int thumbMaxH = int.Parse(config["ThumbnailMaxHeight"]);
        int thumbMaxW = int.Parse(config["ThumbnailMaxWidth"]);
        int maxPageNum = int.Parse(config["DocumentMaxPageNum"]);
        double readScale = double.Parse(config["ImageReadScale"]);
        int readDpi = Convert.ToInt32(dpi * readScale);

        // Create images directory
        string pageImgDir = docRootDir;
        if (!Directory.Exists(pageImgDir))

        // Get the encoder of JPEG
        ImageCodecInfo jpgEncoder = GetCodecInfo();
        //EncoderParameters encParams = GetEncoderParams();

        EncoderParameters encParams = GetEncoderParams(int.Parse(config["ImageJpegQuality"]));

        // Instantiate the License class
        Aspose.Cells.License license = new Aspose.Cells.License();

        // Convert .doc and .docx file to PDF.
        Workbook book = new Workbook(docStream);

        //Define ImageOrPrintOptions
        ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
        //Specify the image format
        imgOptions.ImageFormat = ImageFormat.Png;
        imgOptions.VerticalResolution = readDpi;
        imgOptions.HorizontalResolution = readDpi;

        int totalPageCount = 0;
        foreach (Worksheet sheet in book.Worksheets)
            //Render the sheet with respect to specified image/print options
            SheetRender sr = new SheetRender(sheet, imgOptions);

            for (int i = 0; i < sr.PageCount; i++)

                if (totalPageCount <= maxPageNum)
                    //Render the image for the sheet
                    string imgFile = string.Format("{0}_{1:D8}.jpg",
                            Path.GetFileNameWithoutExtension(docName), totalPageCount);
                    string imgPath = Path.Combine(pageImgDir, imgFile);
                    using (Bitmap bitmap = sr.ToImage(i))
                        // Export image file
                        bitmap.SetResolution(dpi, dpi);
                        bitmap.Save(imgPath, jpgEncoder, encParams);

                        // Add  PageInfo List

            if (totalPageCount >= maxPageNum) break;

        // return results with flag of max page limit over
        return pageInfoList;

They are parameters.

// Get config setting
Create Appseting key value for async function
Dictionary<string, string> config = new Dictionary<string, string>();
config.Add("DocumentsFilePath", outDir);
config.Add("ImageDPI", "96");
config.Add("ImageReadScale", "1.25");
config.Add("ThumbnailMaxHeight", "252");
config.Add("ThumbnailMaxWidth", "210");
config.Add("ImageJpegQuality", "80");
config.Add("DocumentMaxPageNum", "1000");

Thank you,


Thanks for using Aspose APIs.

SheetRender class only renders the sheet defined in SheetRender constructor. So, the total page count is only the sheet’s page count. Please try WorkbookRender to render the whole workbook to tiff image.

Thanks for your reply,

ToImage method of WorkbookRender class can create only multi pages TIFF image. Then I should convert multi pages TIFF image to JPEG images, right?



Thanks for your feedback and using Aspose APIs.

We are afraid, these methods which are available in SheetRender are missing in WorkbookRender, so we will look into it and implement them if feasible. Once, we will have some news for you, we will update you asap.

This issue has been logged as

  • CELLSNET-46174 - WorkbookRender.ToImage(pageIndex, fileName/stream) and Bitmap WorkbookRender.ToImage(int pageIndex) are needed


Thanks for using Aspose APIs.

This is to inform you that we have fixed your issue CELLSNET-46174 now. We will soon provide the fix after performing QA and including other enhancements and fixes.


Thanks for using Aspose APIs.

Please download and try the following fix for your issue CELLSNET-46174 and let us know your feedback.

We have now added APIs:

  • WorkbookRender.ToImage(pageIndex, fileName/stream)
  • WorkbookRender.ToImage(int pageIndex)

Thanks for your reply,

I tried Aspose.Cells 18.5.7 and new ToImage method.
It works well.



Good to know that your issue is sorted out by the new fix. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

The issues you have found earlier (filed as CELLSNET-46174) have been fixed in Aspose.Cells for .NET 18.6. Please also check the document/article for your reference: