OpenXml SDK - 图像重用

发布于 2024-08-09 18:58:49 字数 288 浏览 0 评论 0原文

我正在根据模板创建一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谷夏 2024-08-16 18:58:49

我使用 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.

夏了南城 2024-08-16 18:58:49

最好的方法是打开 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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文