none
Microsoft Word | Exporting Images RRS feed

  • Question

  • Hi, 

    I'm selecting an image and saving it with code such as:

                    

               byte[] img = Globals.ThisAddIn.Application.Selection.EnhMetaFileBits;

              using (var ms = new MemoryStream(img)) 
                {
                    Image image = System.Drawing.Image.FromStream(ms);

                    image.Save(@"I:\ja.bmp", ImageFormat.Png);
                }

    The exported image seems to be surrounded by extra space. For example, when I click on the image in Word the bounding box sits quite tightly around the image. When I save it using the code above I get two, or three times the image width either side of the image and extra space at the top.

    This make it very difficult to use the image in any external program as the bounds of the image are unknown, they have no relationship - that I can see - to the width and height of the associated Shape object?

    Any advice to would greatly appreciated.

    Martin


    Wednesday, January 16, 2019 1:49 PM