We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Partially missing character when converting image

Hello team,

Thank you for your support.

PQ2322.zip (314.6 KB)
1.jpg (198.8 KB)
2.jpg (186.2 KB)

I have converted PQ2322.xlsx to images with Aspose.Cells 17.8. Please find error portions at jpg files.

  1. partially missing character.
  2. line break

This is my code.

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

@PFU.DSOL2

Thanks for using Aspose APIs.

We have tested your issue with the following sample code and found, when we autofit rows and columns, this issue occurs. We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, it is resolved or we have some other news for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-45605 - Partially missing characters when converting to image

Download Links:
sheet1.png (48.5 KB)
sheet2.png (42.9 KB)

C#

Workbook wb = new Workbook("PQ2322.xlsx");

Worksheet ws0 = wb.Worksheets[0];
Worksheet ws1 = wb.Worksheets[1];

ws0.AutoFitRows(true);
ws1.AutoFitRows(true);

ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.ImageFormat = ImageFormat.Png;
opts.OnePagePerSheet = true;

SheetRender sr0 = new SheetRender(ws0, opts);
SheetRender sr1 = new SheetRender(ws1, opts);

sr0.ToImage(0, "sheet1.png");
sr1.ToImage(0, "sheet2.png");

@PFU.DSOL2

Please share the font “Meiryo UI” which is used in your file and the pdf files saved by Microsoft Excel and Aspose.Cells.

Please also show more details about “line break” problem.

Hello team,

Thank you for your support.

the pdf file saved by MS2010
PQ2322_AsPDF_BY_Excel2010.pdf (464.1 KB)
the pdf file by ASPOSE
PQ2322.xlsx.pdf (208 KB)

Regarding Meiryo UI, Please refer to following pages if you use Windows 10.

Thank you,
PFU DSOL2

@PFU.DSOL2

We have logged your comment in our database for evaluation. Once, there is some news for you, we will update you asap.

@PFU.DSOL2,

This is to inform you that we have fixed your issue (logged earlier as “CELLSNET-45605”). We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@PFU.DSOL2

Please download and try the following fix and let us know your feedback.

It works fine. Thank you.

@PFU.DSOL2

Thanks for your feedback and using Aspose.Cells.

It is good to know that your issue is resolved with the latest fix. Let us know if you encounter any other issue, we will be glad to look into it and help you further.

The issues you have found earlier (filed as CELLSNET-45605) have been fixed in Aspose.Cells for .NET 17.9.