Problem with extracting embedded PDF from PPT

Dear becky_bai,

Please try Aspose.Slides 2.6.11.0 . I have tested my code on it and it works fine there. I will also test it on newer version to check whether if something is broken again while fixing the last issue. Here is my code.

void ExtractPDF()
{
    Presentation srcPres = new Presentation("srcPDF.ppt");
    Slide fstSlide = srcPres.GetSlideByPosition(1);
    OleObjectFrame oleObjFrm = fstSlide.FindShape("PDFObject") as OleObjectFrame;
    FileStream fout = new FileStream("c:\\PDFDoc.pdf", FileMode.Create, FileAccess.Write);
    fout.Write(oleObjFrm.ObjectData, 0, oleObjFrm.ObjectData.Length);
    fout.Flush();
    fout.Close();
}

Dear becky_bai,

I don’t find anything wrong in your code and it works perfectly well on latest release of Aspose.Slides 2.6.12.0

I have attached the source presentation and output pdf document for you to view/use them.

void ExtractPDF()
{
    Presentation srcPres = new Presentation("srcPDF.ppt");
    Slide fstSlide = srcPres.GetSlideByPosition(1);
    OleObjectFrame oleObjFrm = fstSlide.FindShape("PDFObject") as OleObjectFrame;

    using (BinaryWriter writer = new BinaryWriter(File.Open("c:\\OutputPDF.pdf", FileMode.Create)))
    {
        writer.Write(oleObjFrm.ObjectData);
    }
}

Thanks.

I couldn't find the download for 2.6.11.0, it seem to be deleted. If you get a chance to try the code on 2.6.12.0, please let me know the result.

Appreciate your help!

Dear becky_bai,

I have already tested it on Aspose.Slides 2.6.12.0. Please see my above post.

I tried to extract pdf from the example ppt you send, it works. But it doesn’t work for any ppt I created. I want to send you an example, is there a way I can do attachment?

Dear becky_bai,

You can send me your file by attaching it with this post. Follow these steps

[Reply] – > [Options] – > [Add/Update]

Do not use [Quick Reply] button, user [Reply] button.

Please see the attached example. Thanks for your help!

Sorry, here is the attachment. The pdf file is what I extracted using Aspose.Slides. The ppt file is the containing file. Thanks!

Dear becky,

I have seen this problem, but to investigate it further, I need the stand alone PDF document, which is embedded inside the PowerPoint Presentation.

I have attached the pdf. Thanks for looking into the issue.

Dear becky_bai,

Thank you for submitting the PDF document. You need to download the latest version of Aspose.Slides 2.6.13.0 from here. There is no such problem with it and everything seems to be fine, please check it.

I tried version 2.6.13.0, I still seem to have the same issue, I noticed that version 2.6.13.0 has the same file size as 2.6.12.0, could you check if the new version is uploaded?

Thanks!

Dear becky_bai,

I found out that this is not a version problem, actually it depends how we insert PDF document inside the PowerPoint presentation.

For example, in the attached archive, you will find two PPT files, one is yours, which does not work but the other is mine which extracts the PDF fine.

I inserted your Hello.pdf document inside my presentation using these steps,

[insert] – > [Object] – > [Object Type Adobe Acrobat 7.0]

I am using PowerPoint 2003. Further, which Adobe Acrobat version you are using. Have you tested other PDF documents? Do they also cause such a problem?

This is my code.

void ExtractPDF()
{
    //This won't work
    //Presentation srcPres = new Presentation("testEmbedded.ppt");
    //But this works fine
    Presentation srcPres = new Presentation("testEmbedded2.ppt");
    Slide fstSlide = srcPres.GetSlideByPosition(1);
    OleObjectFrame oleObjFrm = fstSlide.FindShape("PDFObject") as OleObjectFrame;

    using (BinaryWriter writer = new BinaryWriter(File.Open("PDFDoc.pdf", FileMode.Create)))
    {
        writer.Write(oleObjFrm.ObjectData);
    }
}

Dear becky_bai,

I found out that this is not a version problem, actually it depends how we insert PDF document inside the PowerPoint presentation.

For example, in the attached archive, you will find two PPT files, one is yours, which does not work but the other is mine which extracts the PDF fine.

I inserted your Hello.pdf document inside my presentation using these steps,

[insert] – > [Object] – > [Object Type Adobe Acrobat 7.0]

I am using PowerPoint 2003. Further, which Adobe Acrobat version you are using. Have you tested other PDF documents? Do they also cause such a problem?

This is my code.

void ExtractPDF()
{
    //This won't work
    //Presentation srcPres = new Presentation("testEmbedded.ppt");
    //But this works fine
    Presentation srcPres = new Presentation("testEmbedded2.ppt");
    Slide fstSlide = srcPres.GetSlideByPosition(1);
    OleObjectFrame oleObjFrm = fstSlide.FindShape("PDFObject") as OleObjectFrame;

    using (BinaryWriter writer = new BinaryWriter(File.Open("PDFDoc.pdf", FileMode.Create)))
    {
        writer.Write(oleObjFrm.ObjectData);
    }
}

The ppt you created has the pdf inserted as an image (by the way, how did you do that, I can't seem to do it), I inserted the pdf as an icon and I insert it using Insert->Create from file, then choose an existing file.

I am using Powerpoint 2003 sp2, and Acrobat 6.0 standard.

I tested using the pdf you gave me to insert into a ppt, I can't extract it properly either, so I guess it is not a pdf issue.

I attached another test, the embedded pdf is not created by me. Can you take a look to see whether it works for you?

Or maybe it is the case that if embed pdf as image as you did, extract will work fine, but if embed as icon, it won't?

Thanks for looking into this.

Dear becky,

I will report this problem. If PDF document is in the form of image, it can be extracted but when it is in the form of icon, it gets corrupted during extraction.

Can you tell me, how do you insert PDF document as an icon? Because when I insert, it is inserted as an image.

Here is what I did: Insert -- >Object --> Create from file --> Select a file and then check the "Display as Icon" checkbox.

I will check back the forum daily, whenever you know please let me know the estimated time of this fix.

Thank you!

Is there an estimated date of this fix yet? Thanks!

Dear becky,

The estimated time is either this weekend or the next weekend.

I see there is a new version out, I tried and it fixes the problem.

Thanks! Really impressed by how responsive you guys are!