Embedding Pdf with OpenXml in PowerPoint fails for newer versions

0

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

c#
pdf
powerpoint
openxml
ole
asked on Stack Overflow Jun 10, 2015 by Holger Leichsenring • edited Oct 29, 2020 by Tyr

1 Answer

0

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.

answered on Stack Overflow Jun 11, 2015 by Holger Leichsenring • edited Oct 28, 2020 by Tyr

User contributions licensed under CC BY-SA 3.0