问题描述
我需要通过OpenXml在PowerPoint中以编程方式嵌入Pdf文档.据此:使用C#将文件嵌入到Open XML文档中可以通过OLE32实现. StgCreateStorageEx方法可创建必要的图片以及oleobject.
I need to progammatically embed Pdf documents in PowerPoint via OpenXml. According to this: Embedding files into Open XML documents using C# it is possible via OLE32.StgCreateStorageEx methods to create the necessary picture as well as the oleobject.
不幸的是,这不适用于当前版本的PDF. 在64位操作系统上,这似乎仅适用于Abobe 9版本.更高版本的版本失败,错误代码0x8000FFFF转换为灾难性故障.经过测试后,这实际上是正确的.即使版本9也不可靠.
Unfortunately this doesn't work with current versions of PDF. On a 64 bit OS, this seems to work only with Abobe version 9.Higher version fails with error code 0x8000FFFF which translates to Catastrophic failure. This is actual true after testing it. Even the version 9 does not work reliable.
作为备用,我使用了Google的 pdfium 从首页创建png .不幸的是,这只是成功的一半,因为合并的oleobject与原始对象大不相同.直到用户尝试通过Powerpoint中的双击来打开嵌入式文档时,这才有好处.然后出现一条错误消息,提示找不到该文档的应用程序.
As a fallback, I used pdfium by google to create a png from the first page. This unluckily is only half the way, as the incorporated oleobject is very different from the original one. That does not hurt until the user tries to open the embedded document via doubleclick within Powerpoint. Then an error message comes up, saying the application of the document cannot be found.
这是我的问题:
- 有没有人知道如何改进该程序以使其即使从不使用版本也可以正常工作?
- 有人知道对pdf之类的类似对象进行合并需要对pdf文档进行哪些更改吗?
任何提示都值得赞赏
推荐答案
最后,我让它运行了.在此处进行解释.
Finally I made it running. Have a look here for explanation.
与使用C#将文件嵌入Open XML文档中的代码相比,实际上只有一个区别. .调用时,必须使用StgCreateStorageEx OLE32.STGFMT.STGFMT_DOCFILE代替STGFMT_STORAGE.
Actually there is only one difference compared to the code in Embedding files into Open XML documents using C# . When calling, StgCreateStorageEx OLE32.STGFMT.STGFMT_DOCFILE has to be used instead of STGFMT_STORAGE.
这使得它甚至可以在更新的Adobe版本上运行.
That makes it running even with newer Adobe versions.
这篇关于对于较新的版本,在PowerPoint中将Pdf与OpenXml嵌入失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!