I'm trying to retrieve the Ole Objects from PresentationEx:
foreach (SlideEx slide in presentation.Slides) { foreach (ShapeEx shape in slide.Shapes) { if (shape is OleObjectFrameEx) { var oleFrame = (OleObjectFrameEx)shape; if (!oleFrame.IsObjectLink) { File.WriteAllBytes(GetFileName(oleFrame.ObjectProgId), oleFrame.ObjectData); } } } } This Fails for some type of attachments like pdf, or xlsx.
The same code works fine when working wit Presentation.
I have worked observed the code snippet shared by you and it seems OK. There is one more code snippet that you can find in this documentation link as well for extracting the Ole frames. If there is still an issue then please share the sample presentation with problematic Ole frame types and I will investigate the issue further on my end to help you out.
I've attached a Test Document (I had to rename the AsposeTest.pptx to AsposeTest.pptx.remove, because our proxy doesn't allow to upload documents, so i had to trick it... ;-) just remove .remove to get the .pptx)
The pptx contains two ole objects. One is a pdf and one is a docx. With the above code i can successfuly extract the docx and save it as a file, but the pdf is somehow invalid or corrupted.
I have worked with the presentation file shared by you and it seems to an issue while extracting the PDF from Ole frame. An issue with ID SLIDESNET-33669 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.