OpenXml SDK - 图像重用
我正在根据模板创建一个Word文档。该模板的标题部分包含一个图像,我想在文档的其他地方重复使用该图像。
图像存储在package ->; word/media/myImage.jpeg
所以我需要以某种方式向我希望再次显示图像的每个部分添加关系。我已经手动尝试成功,问题是如何使用sdk 2.0。
使用 AddImagePart()
方法是没有用的,因为这只是再次添加图像,这很愚蠢,因为我只需要一份副本,而不是存储在包中的多个副本。
有人透露一些信息吗?
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 package.
Anyone shed some light?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用 SDK 2.0 的经验主要是在 SpreadsheetML 中,但假设在 WordprocessingML 中使用相同的原理,您需要通过获取其 ID(使用 GetIdOfPart() 方法)然后调用 CreateRelationshipToPart( ) 将保存对其的辅助引用的部分的方法。
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.
最好的方法是打开 DocumentReflector.exe 中的文档并查看生成的代码
Eric 有一些关于该内容的博客文章 http://blogs.msdn.com/ericwhite/
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/