开发者

OpenXml SDK - Image Reuse

I am creating a Word document based on a template. The template contains a image in the header section which I would like to re-use elsewhere in the document.

The image is stored in the package -> word/media/myImage.jpeg so I need to somehow add a relationship to my each section that I wish to display the image again. I have attempted this successfuly manually, the question is how using the sdk 2.0.

Using the AddImagePart() method is useless as this just adds the image again which is silly as I only need one copy rather than several duplicates stored in the pa开发者_JAVA百科ckage.

Anyone shed some light?


My experience with the SDK 2.0 is primarily in SpreadsheetML, but assuming the same principles are used in WordprocessingML, you need to create a relationship to the existing ImagePart, by obtaining its ID (using the GetIdOfPart() method) and then calling the CreateRelationshipToPart() method on the part that will hold the secondary reference to it.


Best way is to open up the document in DocumentReflector.exe and have a look on the code generated

Eric has some blog posts about that http://blogs.msdn.com/ericwhite/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜