Cell text alignment is changed in the converted image

Hi,

When converting a cell with multiple fonts to an image, I noticed the some text alignment is changed, which is different from Ms Office behaviour.

Code:
var workbook = new Workbook(@“test.xlsx”);
var options = new ImageOrPrintOptions
{
ImageFormat = ImageFormat.Emf,
ChartImageType = ImageFormat.Emf,
OnlyArea = false,
TextRenderingHint = TextRenderingHint.ClearTypeGridFit,
OnePagePerSheet = true
};
SheetRender render = new SheetRender(workbook.Worksheets[0], options);
render.ToImage(0, @“test.emf”);

I’ve attached the test file and a screenshot for your reference where I pointed out the issue. Please note in cell A1, the Asian text “雅黑” is in ‘SimHei’ while the Latin text ‘abc’ is in ‘Arial Black’ font. Could you please look into this?

Thanks
test.zip (7.9 KB)
screenshot.png (22.9 KB)

@ServerSide527,

Thanks for the template file, screenshot and sample code.

We noticed the issue as you mentioned via screenshot. But to evaluate your issue precisely, kindly provide “SimHei” font file(s), we will test your issue soon and log it into our database.

Hi, The attachment seems too large to upload (there’s a limit of 3MB on this forum but the single true type font zip file is 4.8MB). Could you please let me know if there’s an alternative way to provide the font file? Otherwise you may download the font file from https://fontzone.net/font-download/simhei. Thanks

@ServerSide527

Thanks for using Aspose APIs.

We were able to observe this issue and logged it in our database for investigation and for a fix. Once, the issue is resolved or we have some other news for you, we will update you asap.

This issue has been logged as

  • CELLSNET-45779 - Cell text alignment is changed in the converted image

@ServerSide527

Thanks for using Aspose APIs.

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

@ServerSide527

Thanks for using Aspose APIs.

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

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

Please also check the following article:

Hi,

Thanks for the fix.

It initially looked ok in the output, but when I changed the font for the Latin text ‘abc’ from ‘Arial Black’ to ‘Calibri’, the issue happens again (see screenshot)
image.png (2.1 KB)
test2.zip (6.0 KB)

I’ve tested the new test file for your reference. Could you please take a further look?

@ServerSide527,

I did confirm the issue as you have mentioned via screenshot using your template file. I found the cell’s text alignment (having mixed fonts) is changed in the converted image. I have logged a separate ticket with an id “CELLSNET-45949” for your issue. We will look into it soon.

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

@ServerSide527,

Please try our latest version/fix: Aspose.Cells for .NET v18.2.6 (.NET 4.0).

Your issue “CELLSNET-45949” should be fixed in it as I tested.

Let us know your feedback.

Hi,

Many thanks for the quick update, I have tested and noticed the alignment is much better with Calibri now.

However, I noticed an interesting fact that if I put a cell with same alignment setting but only with one font, next to the original cell, and render both cells, the result looks not very aligned again:
image.png (5.4 KB)

I’ve attached this new file and screenshot for your reference, is there anything that could improve this?
test3.zip (7.8 KB)

Thanks

@ServerSide527,

Thanks for providing us new file and screenshot with details.

After an initial test, when converting the cells (one cell is using multiple fonts and next cell with single font) to an image, I noticed the the text alignment is not Ok, which is again a bit different from MS Excel behavior.
e.g
Sample code:

var workbook = new Workbook(@"test3.xlsx"); 
var options = new ImageOrPrintOptions 
{ 
ImageFormat = ImageFormat.Emf, 
ChartImageType = ImageFormat.Emf, 
OnlyArea = false, 
TextRenderingHint = TextRenderingHint.ClearTypeGridFit, 
OnePagePerSheet = true 
}; 
SheetRender render = new SheetRender(workbook.Worksheets[0], options); 
render.ToImage(0, @"test.emf"); 

I have logged a separate ticket with an id “CELLSNET-45963” for your issue. We will look into it soon.

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

The issues you have found earlier (filed as CELLSNET-45949) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi

The issues you have found earlier (filed as CELLSNET-45949) have been fixed in this update. Please also check the following article:* <a href="Install Aspose Cells through NuGet|Documentation