Position/scale image after programmatically pasting it into bookmark range

心不动则不痛 提交于 2019-12-25 08:14:31

问题


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:

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:


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



来源:https://stackoverflow.com/questions/9666624/position-scale-image-after-programmatically-pasting-it-into-bookmark-range

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!