Position/scale image after programmatically pastin

2019-09-02 10:56发布

I'm creating a Word 2010 document using C# and Microsoft.Office.Interop.Word. Using the Range.Paste method, I insert a bitmap (from RAM) at a specified bookmark:

Word.Bookmark bookmark = document.Bookmarks.get_Item(ref oBookmark);
Clipboard.SetDataObject(image);
bookmark.Range.Paste();

This bookmark is placed inside a frame (created with the "Insert Frame" command), hence the pasted image is placed inside the frame. Now, the image is automatically scaled to fit the frame horizontally. This is good! But, it does not perform this type of scaling vertically! This causes the bottom of the image to be obscured by any object under the frame:

Image not scaled vertically

Frame A should not be resized!

Q: How can I make sure the image is scaled both horizontally and vertically, keeping the frame's original size?

1条回答
对你真心纯属浪费
2楼-- · 2019-09-02 11:46

Solution: Read the size of the frame and then properly scale the image before pasting it.

查看更多
登录 后发表回答