Shape of parentheses when converting image

Hello team,

I have converted 0_35.xlsx to a image with Aspose.Cells. Please find error points with 0_35_00000001.jpg.

  • Shape of parentheses.

This is my code.

--------------------

public static List ConvertExcelToImage(string docName, MemoryStream docStream, Dictionary 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
{

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



// Export thumbnail file

//string thumbFilename = string.Format(@"{0}_thumb.jpg", Path.GetFileNameWithoutExtension(imgPath));

//string thumbPath = Path.Combine(Path.GetDirectoryName(imgPath), thumbFilename);

//float scale = (float)Math.Min((double)thumbMaxW / bitmap.Width, (double)thumbMaxH / bitmap.Height);

//int thumbW = System.Convert.ToInt32(bitmap.Width * scale);

//int thumbH = System.Convert.ToInt32(bitmap.Height * scale);

//using (Bitmap thumbBmp = new Bitmap(thumbW, thumbH))

//{

// thumbBmp.SetResolution(dpi, dpi);



// using (Graphics graph = Graphics.FromImage(thumbBmp))

// {

// graph.DrawImage(bitmap, 0, 0, thumbW, thumbH);

// }

// thumbBmp.Save(thumbPath, jpgEncoder, encParams);

//}



// TODO Create OCR XML



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

Hi,

Please try our latest version/fix: Aspose.Cells for .NET v17.5.2 (attached).

I have tested your scenario/ case a bit using the simplest lines of code to convert the shape (in the template file) to image file, it works ok, see the attached output image for your reference:
e.g
Sample code:

int readDpi = Convert.ToInt32(96 * 1.25);

Workbook book = new Workbook("e:\\test2\\0_35.xlsx");

Worksheet sheet = book.Worksheets[0];

//Define ImageOrPrintOptions

ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();

//Specify the image format

imgOptions.ImageFormat = ImageFormat.Png;

imgOptions.VerticalResolution = readDpi;

imgOptions.HorizontalResolution = readDpi;


sheet.Shapes[0].ToImage(“e:\test2\out1.png”, imgOptions);

In case you still find the issue with the latest version/fix, kindly do post us details with sample code (runnable) and screenshot, we will check it soon.

Thank you.

Hello team,

Thank you for your support

I have tried 17.5.2 however it doesn’t work in my environment. I have attached jpg.

The phenomenon also happens in case of converting to PDF. I have attached pdf.

e.g sample for converting pdf.


----

// Instantiate the License class

Aspose.Cells.License license = new Aspose.Cells.License();

license.SetLicense(“Aspose.Total.lic”);



// Convert .xls and .xlsx file to PDF.

Workbook book = new Workbook(docStream);

book.Save(pdfStream, Aspose.Cells.SaveFormat.Pdf);

----

Thank you,

PFU DSOL2

Hi,


Thanks for providing us sample files and sample code.

I am able to reproduce the issue as you mentioned by converting your template file to PDF/image. I found that the shape of parentheses is rendered wrong in output PDF/image. The issue is logged as:
  • CELLSNET-45389 - Shape of parentheses is rendered wrong in output PDF/image

Our concerned developer from product team will evaluate your issue soon.

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

Thank you.

Hi,


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


Thank you.
Hi,

Please try our latest version/fix: Aspose.Cells for .NET v17.5.9:

Aspose.Cells for .NET v17.5.9 (.NET 2.0) compiled in .NET Framework 2.0.
Aspose.Cells for .NET v17.5.9 (.NET 4.0) compiled in .NET Framework 4.0.

Your issue should be fixed in it.

Let us know your feedback.

Thank you.

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


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.