Search code examples
c#asp.netpowerpointopenxml-sdkpowerpoint-automation

The document cannot be opened because there is an invalid part with an unexpected content type


I am getting a error while opening using a presentation (PPTX files) creation code. Code i am using is given below:

  public static void UpdatePPT()
    {
        const string presentationmlNamespace = "http://schemas.openxmlformats.org/presentationml/2006/main";
        const string drawingmlNamespace = "http://schemas.openxmlformats.org/drawingml/2006/main";

        string fileName = Server.MapPath("~/PPT1.pptx");  //path of pptx file


        using (PresentationDocument pptPackage = PresentationDocument.Open(fileName, true))
        {


        } // Using pptPackage
}

and the error i am getting is:

"The document cannot be opened because there is an invalid part with an unexpected content type. 
[Part Uri=/ppt/printerSettings/printerSettings1.bin], 
[Content Type=application/vnd.openxmlformats-officedocument.presentationml.printerSettings], 
[Expected Content Type=application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings]."

error occurs at using (PresentationDocument pptPackage = PresentationDocument.Open(fileName, true))

Code works fine for many PPTX files. But it is throwing this error on some files. I am not able to find any solution. Thanks for your help.


Solution

  • Finally i have solved my problem. The PPTX i got was developed in mac os. So what i did is i just opened a working pptx file. And copied all the contents of not working pptx into working pptx and saved it by the name of not working pptx.