Characters overlap when converting to image


#1

Hello,

I have converted PQ2317.xlsx to a image with Aspose.Cells 17.9. Please find error portions in 1.jpg.
PQ2317.zip (20.1 KB)
1.jpg (43.7 KB)

  1. Characters overlap.
  2. Cell’s color

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

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,


#2

@PFU.DSOL2

We were able to observe the issues as per your description and logged them in our database for investigation and for a fix. Once, the issues are resolved or we have some other news for you, we will let you know asap.

These issues have been logged as

  • CELLSNET-45669 - Characters overlap when converting to Image
  • CELLSNET-45670 - Cells color is lost on converting to Image

#3

@PFU.DSOL2,

The following issue is resolved now.

  • CELLSNET-45670 - Cells color is lost on converting to Image

We will provide the fix after incorporating other fixes and enhancements.


#4

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


#5

@PFU.DSOL2,

The following issue is also resolved now:

CELLSNET-45669 - Characters overlap when converting to Image

We will soon provide you the fix after incorporating other enhancements and fixes.


#6

The issues you have found earlier (filed as CELLSNET-45669) have been fixed in this Aspose.Cells for .NET 17.11 update.

Please also check the following article:


#7

Thank you for your support.
I have checked CELLSNET-45669 and similar phenomenon has happend in 17.11 with the follwoing file.
PQ2317_2.zip (19.6 KB)


#8

@PFU.DSOL2,

I tried downloading your attachment but it gives me error page, there seems to me something wrong with your attachment. Could you try attaching the zip file again, we will check it soon.


#9

Here you are.
PQ2317_2 (2).zip (19.8 KB)
Thank you.


#10

@PFU.DSOL2,

Thanks for providing the new template file.

You are right, I am able to reproduce the same issue “Characters overlap when converting to Image” using your newly attached file. I have reopened the issue “CELLSNET-45669” again. Our concerned developer from product team will evaluate your issue soon.

Once we have an update on it, we will let you know here.


#11

@PFU.DSOL2,

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


#12

@PFU.DSOL2

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


#13

The issues you have found earlier (filed as CELLSNET-45669) have been fixed in this Aspose.Cells for .NET 18.1 update.

Please also check the following article: