Embedding Pdf with OpenXml in PowerPoint fails for newer versions

情到浓时终转凉″ 提交于 2019-12-12 04:05:05

问题


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.

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.

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.

Here my questions:

  • Has anyone information about how to improve the procedure to make it working even with never versions?
  • Does anybody know what the changes to the pdf document are that are necessary to incorporate a similar object like pdf does it?

Any hint is highly appreciated


回答1:


Finally I made it running. Have a look here for explanation.

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.

That makes it running even with newer Adobe versions.



来源:https://stackoverflow.com/questions/30758661/embedding-pdf-with-openxml-in-powerpoint-fails-for-newer-versions

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