@ServerSide527,
After investigating our Aspose.Cells generated EMF file, Microsoft Excel generated EMF file and Microsoft Word generated PDF file, we find that it is the EMF plus records in the image that cause Microsoft Word treating the text in the image as paths/canvas.
Our Aspose.Cells generated EMF file and Microsoft Excel generated EMF file are both EmfPlusDual type. Our Aspose.Cells generated EMF file has EMF plus records like “EmfPlus-DrawString” record, but Microsoft Excel generated EMF file doesn’t have EMF plus records like “EmfPlus-DrawString” record and it uses “EmfPlus-GetDC” record to indicate that using the subsequent EMF only records.
Using the following code to remove EMF plus records, the generated EMF file will be Ok.
e.g
Sample code:
var book = new Workbook("test.xlsx");
Worksheet sheet = book.Worksheets[0];
var options = new ImageOrPrintOptions
{
ImageFormat = ImageFormat.Emf,
OnePagePerSheet = true,
};
using (MemoryStream ms = new MemoryStream())
{
new SheetRender(sheet, options).ToImage(0, ms);
ReSaveImageToEmfOnly(ms, "test.emf");
}
//convert function code:
internal static void ReSaveImageToEmfOnly(Stream srcStream, String destPath)
{
Bitmap dummyBitmap = null;
Graphics dummyGfx = null;
IntPtr hdc = IntPtr.Zero;
System.Drawing.Imaging.Metafile metafile = null;
try
{
dummyBitmap = new Bitmap(1, 1);
dummyGfx = Graphics.FromImage(dummyBitmap);
hdc = dummyGfx.GetHdc();
Image srcImage = Image.FromStream(srcStream);
Rectangle rect = new Rectangle(0, 0, srcImage.Width, srcImage.Height);
metafile = new System.Drawing.Imaging.Metafile(destPath, hdc, rect, System.Drawing.Imaging.MetafileFrameUnit.Pixel, EmfType.EmfOnly);
Graphics graphic = Graphics.FromImage(metafile);
graphic.DrawImage(srcImage, rect);
srcImage.Dispose();
graphic.Dispose();
}
finally
{
if (metafile != null)
{
metafile.Dispose();
}
if (hdc != IntPtr.Zero)
{
dummyGfx.ReleaseHdc(hdc);
}
if (dummyGfx != null)
{
dummyGfx.Dispose();
}
if (dummyBitmap != null)
{
dummyBitmap.Dispose();
}
}
}
Let us know if you still have any issue.
Thank you.