Export chart to EMF are very poor quality when run on different computer

Hi

I am using Aspose to load data into an Excel template, and copy charts / tables into a Word document. All very nice & fast - Aspose is a powerful piece of software.

This is working fine on my computer (#1), but when I transfer the executable file and Aspose DLLs to a colleagues computer (#2), the charts copied into the Word document are very poor quality.

Both #1 and #2 are running Windows Server 2008, but do not have the same software loaded (#2 does not have visual studio for example).

From looking through the help, it appears that the poor quality charts may be due to interpolation issues. Eg I’ve seen this thread - SheetRender.ToImage returns different images on different servers. But I can’t see where to implement this in my code, see below.

Very grateful for any help on where to implement the interpolation code, or any other ways to improve the quality of the generated charts on Computer #2.

Thanks, Tom.


Dim cht As Aspose.Cells.Charts.Chart = wkbook.Worksheets(0).Charts(0)

Dim image_options As New Aspose.Cells.Rendering.ImageOrPrintOptions
image_options.HorizontalResolution = 300
image_options.VerticalResolution = 300
image_options.IsCellAutoFit = False
image_options.ImageFormat = System.Drawing.Imaging.ImageFormat.Emf
image_options.PrintingPage = PrintingPageType.Default

Dim chart_stream As New MemoryStream
cht.ToImage(chart_stream, image_options)
chart_stream.Position = 0

builderReport.MoveToBookmark(bookmark.Name)
Dim wdChart As Aspose.Words.Drawing.Shape = builderReport.InsertImage(chart_stream)

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Probably, this issue is because of fonts. So, first make sure all the fonts in your first machine (where your code is working fine) are also installed on your other machine (where you code is not working fine).

Please also download and try the latest version and see if it makes any difference: Aspose.Cells
for .NET v7.3.4.3


If above things do not work, then you can try playing with interpolation as this issue might be occurring because default interpolation mode are different on both machines.

Please see the following modified code of yours. Changes are highlighted as red.

VB.NET
Dim cht As Aspose.Cells.Charts.Chart = wkbook.Worksheets(0).Charts(0)

Dim image_options As New Aspose.Cells.Rendering.ImageOrPrintOptions
image_options.HorizontalResolution = 300
image_options.VerticalResolution = 300
image_options.IsCellAutoFit = False
image_options.ImageFormat = System.Drawing.Imaging.ImageFormat.Emf
image_options.PrintingPage = PrintingPageType.Default

Dim chart_stream As New MemoryStream
chart_stream.Position = 0

Dim src_bmp As Bitmap = cht.ToImage()
Dim dst_bmp As Bitmap = New Bitmap(src_bmp.Width, src_bmp.Height)

Dim gr As Graphics = Graphics.FromImage(dst_bmp)
gr.InterpolationMode = Drawing2D.InterpolationMode.High
gr.DrawImage(src_bmp, 0, 0, 332, 430)
dst_bmp.Save(chart_stream, System.Drawing.Imaging.ImageFormat.Emf)


builderReport.MoveToBookmark(bookmark.Name)
Dim wdChart As Aspose.Words.Drawing.Shape = builderReport.InsertImage(chart_stream)