We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Extracting Emedded Objects not working

Please see my code below.
My problem is that when I write this word doc to the disk, it comes in as garbled text only. I open it in MS Word and it is all garbled text. Same thing happens with Excel files.
Please tell what am I missing here?
Also if i apply the same code to embedded pdf files, they come out perfect.
My code below:
Presentation pres = new Presentation(path);
int filenum = 0;
foreach(Slide slide in pres.Slides)
{
foreach (Aspose.Slides.Shape shape in slide.Shapes)
{
filenum += 1;

if (shape.ToString().Contains("OleObjectFrame"))

{

string fileName = @"C:\temp\testAsposeSlides" + filenum + ".doc";

OleObjectFrame oleOF = shape as OleObjectFrame;

FileStream fstr = new FileStream(fileName, FileMode.Create, FileAccess.Write);

byte[] buf = oleOF.ObjectData;

fstr.Write(buf, 0, buf.Length);

fstr.Flush();

fstr.Close();
}
}
}

Dear Aseem,

I don’t know what causes your problem; probably it because of text encoding.

However, I ran your code after little modification on Aspose.Slides 2.9.2.0 and it was successful. Please see the attached source presentation and output document.

----------------------------------------------------

Presentation pres = new Presentation("c:\\source.ppt");

Slide sld = pres.GetSlideByPosition(1);

string fileName = @"C:\testAsposeSlides" + ".doc";

OleObjectFrame oleOF = sld.Shapes[0] as OleObjectFrame;

FileStream fstr = new FileStream(fileName, FileMode.Create, FileAccess.Write);

byte[] buf = oleOF.ObjectData;

fstr.Write(buf, 0, buf.Length);

fstr.Flush();

fstr.Close();