Text underline not appearing correctly when saved as image

Hi team,

I am using the code below on a linux server to create an image from a range, I insert the image into PowerPoint.

private static ImageOrPrintOptions _options = new ImageOrPrintOptions()
{
HorizontalResolution = 300,
VerticalResolution = 300,
OnePagePerSheet = true,
OnlyArea = true,
ImageType = ImageType.Emf
};

The output is attached a long with a image that was copied and pasted on the desktop (as shown when printed and as shown on screen)

Aspose range as image.zip (139.1 KB)

The text in the rows are positioned differently and the underline on the text is too close to the text. The image is also not the same dimensions

Is there a setting to address this issue or a different image type that should be used?

Thanks

@OSJ

It seems you’re experiencing issues with text underlining and positioning when saving a range as an image in Aspose.Cells. Here are a few suggestions to address these problems:

  1. Image Type: Consider using a different image type, such as ImageType.Png or ImageType.Jpeg, as they may handle text rendering differently and could improve the appearance of underlines.

  2. Text Formatting: Ensure that the text formatting in your Excel range is correctly set before rendering. Discrepancies can arise from how the text is formatted in the original document.

  3. Image Options: Adjust the ImageOrPrintOptions settings. For example, setting OnlyArea to false might help capture the entire area of the range, which could affect how the text is rendered.

Here’s a modified version of your code snippet with a different image type:

private static ImageOrPrintOptions _options = new ImageOrPrintOptions()
{
    HorizontalResolution = 300,
    VerticalResolution = 300,
    OnePagePerSheet = true,
    OnlyArea = false, // Change this to false
    ImageType = ImageType.Png // Try using PNG
};
  1. Testing Different Resolutions: Experiment with different resolutions to see if that affects the rendering of the underline and overall text appearance.

If these suggestions do not resolve the issue, consider exploring the Aspose.Cells documentation for more detailed options related to image rendering and text formatting.

Feel free to reach out if you have more questions!

@OSJ
We changed PrintArea because it’s a huge range in the template file:

Workbook c = new Workbook(dir + @"Aspose range as image.xlsx");
 ImageOrPrintOptions _options = new ImageOrPrintOptions()
 {
     HorizontalResolution = 300,
     VerticalResolution = 300,
     OnePagePerSheet = true,
     OnlyArea = true,
     ImageType = ImageType.Emf
 };
 c.Worksheets["Line Chart"].PageSetup.PrintArea = "B1:I6";
 SheetRender render = new SheetRender(c.Worksheets["Line Chart"], _options);
 render.ToImage(0,dir + "dest.emf");

Result emf: emf.zip (3.8 KB)
It looks fine.

Was this created on Linux?

@OSJ
It was created on windows.
Please install all fonts (such as “Calibri”) to linux server .