Incorrect rendering when converting chart to image

Hi Aspose team,
I’ve run into an issue when converting a chart to EMF image. The rendered output is different from the excel chart itself.

Here’s the code I used to generate my test outputs:

string dir = @"C:\Users\";
using (Workbook TemplateWB = new Workbook(dir + @"Test_09052025\Chart_Template.xlsm"))
{
    Worksheet sourceWS = TemplateWB.Worksheets["Demographics"];

    List<string> PrintAreas = new() { "D137:O169", "D205:O237", "D273:O305" };

    for (int i = 0; i < PrintAreas.Count; i++)
    {
        //Set print area
        sourceWS.PageSetup.PrintArea = PrintAreas[i];
        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.Emf,
            HorizontalResolution = 100,
            VerticalResolution = 100,
            OnlyArea = true,
            TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias
        };

        // Take the image of your worksheet
        SheetRender Render = new SheetRender(sourceWS, options);
        Render.ToImage(0, dir + @$"\Test_09052025\Demographics_Chart{i+1}.png");
    }
}

Output:
Test_09052025.zip (3.0 MB)

In comparison 1: The font of values to right of the bar graphs are all set to Arial Narrow in excel. But when aspose renders it at as an EMF image, the font appears to be Calibri.

In comparison 2: The same issue as described in comparison 1.

In comparison 3: The bar chart uses red bars that come from the shadow property of the Excel document. They do not appear in the output from Aspose.

@JThomas98

Hi,

Thank you for providing the sample code and the screenshots.
Below are the reasons why the EMF output differs from the original Excel chart and the steps you can take to obtain a rendering that matches the Excel view as closely as possible.


:one: Font substitution (Arial Narrow → Calibri)

Why it happens

Aspose.Cells renders charts using the fonts that are available on the machine where the code runs.
If Arial Narrow cannot be found, GDI+ falls back to the default UI font (Calibri) – this is exactly what you see in the EMF image.

How to fix it

  1. Install the missing font on the server/machine where the conversion is performed.
  2. If installing the font is not possible, register a custom font folder so that Aspose.Cells can load the font at runtime:
using Aspose.Cells;
using Aspose.Cells.Rendering;

// Register a folder that contains Arial Narrow (or any other required fonts)
FontConfigs fontConfigs = FontConfigs.GetDefaultInstance();
fontConfigs.FontSources.Add(new FolderFontSource(@"C:\MyFonts", true));

// (Optional) If you need to use a specific font collection for this conversion only
FontSettings fontSettings = new FontSettings();
fontSettings.SetFontSources(new IFontSource[] { new FolderFontSource(@"C:\MyFonts", true) });

ImageOrPrintOptions options = new ImageOrPrintOptions
{
    OnePagePerSheet = true,
    ImageType = ImageType.Emf,
    HorizontalResolution = 100,
    VerticalResolution = 100,
    OnlyArea = true,
    TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias,
    FontSettings = fontSettings          // <-- attach the FontSettings
};

Tip: After adding the font source, you can verify that Aspose can see the font:

bool hasArialNarrow = fontSettings.FontSources
                     .SelectMany(fs => fs.GetAllAvailableFonts())
                     .Any(f => f.FontFamilyName.Equals("Arial Narrow", StringComparison.OrdinalIgnoreCase));

If hasArialNarrow returns true, the chart will be rendered with the correct font.


:two: Missing shadow effect on the red bars

Why it happens

The EMF (Enhanced Metafile) format does not support many of the newer shape‑effects that Excel uses (e.g., soft‑edges, shadows, 3‑D bevels).
Aspose.Cells faithfully reproduces the chart data, but the shadow style is omitted because the target format cannot represent it.

Possible work‑arounds

Option Description
Render to a raster format (PNG, JPEG, TIFF) These formats store the visual appearance as pixels, so all shadow/3‑D effects are preserved.
Export to PDF first and then convert PDF → EMF (if you really need EMF) The PDF renderer keeps the shadow, and the subsequent PDF‑to‑EMF conversion can retain it better.
Disable the shadow in Excel if EMF is a hard requirement Since EMF cannot display it, removing the shadow will make the source and output identical.

Sample code – rendering to PNG (keeps the shadow):

ImageOrPrintOptions pngOptions = new ImageOrPrintOptions
{
    OnePagePerSheet = true,
    ImageType = ImageType.Png,          // raster format retains shadows
    HorizontalResolution = 150,
    VerticalResolution = 150,
    OnlyArea = true,
    TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias
};

SheetRender pngRender = new SheetRender(sourceWS, pngOptions);
pngRender.ToImage(0, Path.Combine(dir, $"Demographics_Chart{i + 1}.png"));

If you must have an EMF file, the shadow simply cannot be reproduced because the EMF specifications do not contain such effect information.


:three: Quick checklist to get the closest visual match

:white_check_mark: Item Action
Arial Narrow font available Install on the host or add a custom font folder (see code above).
Use a raster format for full visual fidelity Switch ImageType to Png/Jpeg when shadows are needed.
Upgrade to the latest Aspose.Cells version New releases contain bug‑fixes and better rendering support.
Verify DPI settings Higher DPI (150‑300) reduces visual gaps between Excel and the exported image.
Set PageSetup.PrintArea correctly Ensure the chart is fully inside the defined area.

:four: Helpful links


What to try next

  1. Add the custom font source (or install Arial Narrow) and re‑run the conversion.
  2. If the shadow is essential, change ImageType to Png (or another raster format) and compare the output.
  3. Let us know which combination gives you the desired result, or share a small workbook that reproduces the issue if you need further fine‑tuning.

Feel free to ask any follow‑up questions—​we’re happy to help you get the exact visual output you need!

@JThomas98,

Thanks for the sample file, screenshots and details.

We reproduced both types of issues you have described. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s):

  • CELLSNET-58979 - The font of values changes (Arial Narrow → Calibri) when rendering in the EMF image
  • CELLSNET-58980 - The bar chart uses red bars (using shadow property) are not rendered in the output image

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thanks @amjad.sahi. Looking forward to the fix.

@JThomas98,

You are welcome. We hope your issues will be sorted out soon. Rest assured, we’ll keep you informed as soon as there’s an update on any of the logged issues.

1 Like

Hi @JThomas98
For CELLSNET-58980, the results of our optimization are as follows, it will take effect at 25.10.
CELLSNET58980_250922.png (5.7 KB)

This is looking good. Thanks.

@JThomas98,

Thank you for your feedback. We are glad to hear that you are satisfied with the optimization included in the output image generated by the fix. Please note that this fix/enhancement will be part of the upcoming release (Aspose.Cells v25.10), which is scheduled for the first half of October 2025. Rest assured, we will notify you in this thread as soon as the new version is available.

Sounds good. I hope you can figure out the issue with font before the next release. Thanks!

@JThomas98,

We will try our level best to resolve your other issue (CELLSNET-58979 - The font of values changes (Arial Narrow → Calibri) when rendering in the EMF image) soon. Once we figure it out, we will let you know here.

1 Like

Hi @JThomas98
For CELLSNET-58979, the results of our optimization are as follows, it will take effect at 25.10.
CELLSNET58979_fix.png (3.6 KB)

This is looking good. Thank you for the output.

@JThomas98,

Thank you for your feedback. We inform you that the new version, Aspose.Cells 25.10, is expected to be released between October 10th and 15th, 2025. Rest assured, we will update you in this thread as soon as the new version becomes available.