This looks good too. Thanks
Thanks for your confirmation on the issue (Ticket ID: “CELLSNET-58094”). We will make sure that you get notification post on new version (Aspose.Cells v25.5) once it is available next month.
Moreover, we are glad that using TextRenderingHint = TextRenderingHint.AntiAlias in ImageOrPrintOptions class works for your needs for font kerning issue (Ticket ID: “CELLSNET-58093”).
@amjad.sahi,
I’ve used TextRenderingHint = TextRenderingHint.AntiAlias in ImageOrPrintOptions in ImageOrPrintOptions class and I’m still seeing the issue of the uneven spacing between certain characters.
The code I’ve used is
Document RepDoc = new Document();
DocumentBuilder Builder = new DocumentBuilder(RepDoc);
using (Workbook TemplateWB = new Workbook(dir + @"\Test_04222025\Chart_Template.xlsm"))
{
Worksheet sourceWS = TemplateWB.Worksheets["ExecSummary"];
//Set print area
sourceWS.PageSetup.PrintArea = $"C3:D5";
sourceWS.PageSetup.LeftMargin = 0;
sourceWS.PageSetup.RightMargin = 0;
sourceWS.PageSetup.TopMargin = 0;
sourceWS.PageSetup.BottomMargin = 0;
// Clear any header/footer as they'll be captured when converting the worksheet to image
sourceWS.PageSetup.ClearHeaderFooter();
// Set OnePagePerSheet option as true
ImageOrPrintOptions options = new ImageOrPrintOptions
{
OnePagePerSheet = true,
ImageType = Aspose.Cells.Drawing.ImageType.OfficeCompatibleEmf,
HorizontalResolution = 100,
VerticalResolution = 100,
OnlyArea = true,
TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias
};
// Take the image of your worksheet
SheetRender Render = new SheetRender(sourceWS, options);
// Create a stream to save the image in
MemoryStream ImgStream = new MemoryStream();
Render.ToImage(0, ImgStream); //Returns an image of the cell range if an accuarate cell range is suppiled
if (ImgStream != MemoryStream.Null)
{
// Insert this image into the place of the old shape.
Shape newOleShape = Builder.InsertImage(ImgStream);
Aspose.Words.PageSetup PS = Builder.CurrentSection.PageSetup;
double PageWidth = PS.PageWidth - PS.LeftMargin - PS.RightMargin;
if (PageWidth < newOleShape.Width)
{
newOleShape.Width = PageWidth;
}
}
}
RepDoc.Save(dir + @"\Test_04072025\Output_TextRendering_AntiAlias.docx");
For you convenience, I’ve also included a screenshot of the chart from the excel workbook and I’ve highlighted the problematic areas in red. I’ve also used some other examples to highlight the issue.
This issue seems to be happening with almost all the text in the excel workbook I’ve attached. Somehow the spacing of characters is uneven in aspose.
Test_04222025.zip (8.7 MB)
I can see the issue of the uneven spacing between certain characters. After doing some research, I find that changing ImageType = ImageType.OfficeCompatibleEmf to ImageType = Aspose.Cells.Drawing.ImageType.Emf will get the results that match your screenshots of Excel. I checked all the issues highlighted in Word document, it is OK.
The ImageOrPrintOptions will be
ImageOrPrintOptions options = new ImageOrPrintOptions
{
OnePagePerSheet = true,
ImageType = Aspose.Cells.Drawing.ImageType.Emf,
HorizontalResolution = 100,
VerticalResolution = 100,
OnlyArea = true,
TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias
};
@peyton.xu,
Thank you for this. I no longer have the issue of uneven spacing between characters. Using Emf is the right way to go.
@JThomas98
Thank you for your feedback. You are welcome. I’m glad you solved the issue by using the suggested code. If you have any questions, please feel free to contact us at any time.
Hi @JThomas98
For CELLSNET-58168 ( The shapes that overlap with the x-axis and y-axis are somehow behind the axis),
The results of our optimization are as follows, it will be effective at 25.5.
CELLSNET-58168-fix.png (14.7 KB)
For CELLSNET-58180 ( The font kerning is different from letter to letter), Please also try to resolve it with the parameter settings of ImageOrPrintOptions, thank you.
Fix for CELLSNET-58168 is looking good.
I can confirm that CELLSNET-58180 is fixed by using the following settings:
ImageOrPrintOptions options = new ImageOrPrintOptions
{
OnePagePerSheet = true,
ImageType = Aspose.Cells.Drawing.ImageType.Emf,
HorizontalResolution = 100,
VerticalResolution = 100,
OnlyArea = true,
TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias
};
The fixes will be included in the upcoming Aspose.Cells v25.5 which is scheduled to be published in the first half of May 2025.
Thanks for your feedback. We’re glad that your issue is sorted out by setting ImageOrPrintOptions.
The issues you have found earlier (filed as CELLSNET-57953,CELLSNET-58180,CELLSNET-58094) have been fixed in this update. This message was posted using Bugs notification tool by leoluo