Programmatically extract embedded file from PowerPoint presentation

后端 未结 1 1368
礼貌的吻别
礼貌的吻别 2020-12-21 10:02

I am working on a VSTO PowerPoint add-in which involves recording and playing sounds. I was requested at the last minute to allow users to pick the device that will play the

相关标签:
1条回答
  • 2020-12-21 10:42

    Both are possible.

    1. Extract WAVs from PPTX: All embedded media are in the .pptx\ppt\media folder (rename .pptx to .zip, unzip and nav to \ppt\media). They are usually sequentially numbered in the order they were added and/or processed. Narration, AFAIK, is always embedded and never linked. The problem will be identifying the exact one to extract - that may be taken care by adding a tag or other unique identifier to it when adding to the pptx. The way to extract it is to use the Open XML SDK (or just System.IO.Packaging directly) and open an in-memory copy of the current presentation, locate your .wav in the folder (I use Linq-to-XML to find what I need) and read that into a memory stream for either writing to disk to play or if your add-in can play from a memory stream, even better.

    2. Binary types in PPTX: Anything can go into an Open XML document, but it's making it stay there that is the key. See this answer for details - Is it possible to add some data to a Word document?.

    0 讨论(0)
提交回复
热议问题