Transparency for Emf

Hi,

Given the following code:

var inputFile = "test.xlsx";
var wb = new Workbook(inputFile);
Worksheet sheet = wb.Worksheets.First();
var options = new ImageOrPrintOptions
        {
            ImageFormat = ImageFormat.Emf,
            ChartImageType = ImageFormat.Emf,
            OnlyArea = true,
            TextRenderingHint = TextRenderingHint.ClearTypeGridFit,
            OnePagePerSheet = true
        };

FilePath outFile = "out.emf";
var sheetRenderer = new SheetRender(sheet, options);
sheetRenderer.ToImage(0, outFile);

Vs creating an Emf in Excel:

  • Select the range
  • Copy -> Copy as Picture -> As shown when printed

If you paste the Emf into a Word table with a background colour, the Excel image has a transparent background whereas the Aspose one is white (ref. test.docx).

Is there a way to get the same image with transparency enabled using Aspose?

test.zip (25.2 KB)

Best regards,

@ServerSide527,

Thanks for providing us sample code and template file.

Please add a line (see the line in bold) to your code segment, it will work fine for your requirement:
e.g
Sample code:

var inputFile = “test.xlsx”;
var wb = new Workbook(inputFile);
Worksheet sheet = wb.Worksheets.First();
var options = new ImageOrPrintOptions
{
ImageFormat = ImageFormat.Emf,
ChartImageType = ImageFormat.Emf,
OnlyArea = true,
TextRenderingHint = TextRenderingHint.ClearTypeGridFit,
Transparent = true,
OnePagePerSheet = true
};

FilePath outFile = “out.emf”;
var sheetRenderer = new SheetRender(sheet, options);
sheetRenderer.ToImage(0, outFile);

Hope, this helps a bit.