如题,
word里就一句话;保存后的效果是
代码如下:
Application app = new Application(); Document obj = app.Documents.Open("word路径"); byte[] data = (byte[])obj.Content.EnhMetaFileBits; using (MemoryStream ms = new MemoryStream(data)) { using (Image img = Image.FromStream(ms)) { int w = img.Width; int h = img.Height; using (var target = new Bitmap(w,h)) using (var g = Graphics.FromImage(target)) { g.DrawImage(img, 0, 0, w,h); target.Save(“保存路径”,System.Drawing.Imaging.ImageFormat.Gif); } } }
如果word里有图片,生成的图片里图片是可以显示出来的,文字就没有了;背景也是黑色的;
各位大虾有何高见??
g.DrawImage(img, 0, 0, w,h);这句前面加一句:graphics.Clear(Color.White);