How to ouput header when converting image/PDF

Hello,

I have converted PQ4861_1xlsx to image with Aspose.Cells 17.9 however I can not see header in 1.jpg.
PQ4861_1.zip (5.9 KB)
1.jpg (8.7 KB)

Do you have the option to ouptut header when converting image/pdf.

I have attached PQ2317SaveAsPdfByExcel.pdf which is the pdf that MS Excel outputs as a reference.
PQ4861_1.pdf (17 KB)

This is my code of image conversion.

public static List ConvertExcelToImage(string docName, MemoryStream docStream, Dictionary<string, string> config)
{
try
{
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))
                Directory.CreateDirectory(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();
            license.SetLicense("Aspose.Total.lic");

            // 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++)
                {
                    totalPageCount++;

                    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
                            pageInfoList.Add(imgPath);
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                if (totalPageCount >= maxPageNum) break;
            }

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

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,

@PFU.DSOL2,

I have tested your scenario/case using our latest version/fix: Aspose.Cells for .NET (Latest Version)

it works fine and the output image (attached) is fine with header text on top.

I used the following sample code with your template file, I commented and removed some lines of your code segment to make it work on my end:
e.g
Sample code:

try
{
// Get config setting
//Create Appseting key value for async function
Dictionary<string, string> config = new Dictionary<string, string>();

           config.Add("DocumentsFilePath", "e:\\test2\\");
           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");


            //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);

         // Instantiate the License class
        Aspose.Cells.License license = new Aspose.Cells.License();
        license.SetLicense("Aspose.Total.lic");

        // Convert .doc and .docx file to PDF.
        Workbook book = new Workbook("e:\\test2\\PQ4861_1.xlsx");

        //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++)
            {
                totalPageCount++;

                if (totalPageCount <= maxPageNum)
                {
                    using (Bitmap bitmap = sr.ToImage(i))
                    {
                        // Export image file
                        bitmap.SetResolution(dpi, dpi);
                                                      bitmap.Save("e:\\test2\\out1.png");

                        
                    }
                }
                else
                {
                    break;
                }
            }

            if (totalPageCount >= maxPageNum) break;
        }

    }
    finally
    {
    }

If you still find the issue, kindly do create a separate console demo application (runnable) with v17.9, zip the project and provide us here, we will check it soon.
out1.jpg (7.4 KB)

I still find issue. I have attached my project without lic and Aspose.dlls.
Thank you for your support.

@PFU.DSOL2,

Thanks for the sample project.

I have checked your project a bit but it involves multiple APIs. We appreciate if you could separate the issue regarding Aspose.Cells and create a simple console application (runnable) with few lines of code involving Aspose.Cells APIs only, zip the project and post us here to reproduce the issue, it will help us evaluate your issue precisely and to consequently figure it out soon.

Thank you for your support.
Here is the console application involving Aspose.Cells API only.
AsposeCellsConsoleTest.zip (74.0 KB)

@PFU.DSOL2

The header is a file name, but when the workbook is created from a stream, the user should set the workbook’s FileName as shown in the following screenshot.