Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't open presentations containing 3D objects (MIME type mismatch) #1069

Closed
andrewmolyneux opened this issue Nov 15, 2021 · 11 comments
Closed

Comments

@andrewmolyneux
Copy link

Description

After updating to SDK version 2.14.0 from 2.10.1, I noticed that opening presentations containing 3D objects causes an exception. Error message is similar to "The document cannot be opened because there is an invalid part with an unexpected content type. [Part Uri=/ppt/media/model3d1.glb] [Content Type=model/gltf.binary] [Expected Content Type=model/gltf-binary]."

Information

  • .NET Target: .NET Framework
  • DocumentFormat.OpenXml Version: 2.14.0

Repro

Using this test file created with PowerPoint 2019:
3d.pptx

using System;
using DocumentFormat.OpenXml.Packaging;

namespace ReproOxml3dBug
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var presDoc = PresentationDocument.Open("3d.pptx", false))
            {
                Console.WriteLine("Opened successfully");
            }
        }
    }
}

Observed

An exception occurs as shown below:

[Part Uri=/ppt/media/model3d1.glb],
[Content Type=model/gltf.binary],
[Expected Content Type=model/gltf-binary].
   at DocumentFormat.OpenXml.Packaging.OpenXmlPart.Load(OpenXmlPackage openXmlPackage, OpenXmlPart parent, Uri uriTarget, String id, Dictionary`2 loadedParts)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.LoadReferencedPartsAndRelationships(OpenXmlPackage openXmlPackage, OpenXmlPart sourcePart, RelationshipCollection relationshipCollection, Dictionary`2 loadedParts)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPart.Load(OpenXmlPackage openXmlPackage, OpenXmlPart parent, Uri uriTarget, String id, Dictionary`2 loadedParts)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.LoadReferencedPartsAndRelationships(OpenXmlPackage openXmlPackage, OpenXmlPart sourcePart, RelationshipCollection relationshipCollection, Dictionary`2 loadedParts)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPart.Load(OpenXmlPackage openXmlPackage, OpenXmlPart parent, Uri uriTarget, String id, Dictionary`2 loadedParts)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.LoadReferencedPartsAndRelationships(OpenXmlPackage openXmlPackage, OpenXmlPart sourcePart, RelationshipCollection relationshipCollection, Dictionary`2 loadedParts)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Load(Package _package)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPackage..ctor(PackageLoader& loader, OpenSettings settings)
   at DocumentFormat.OpenXml.Packaging.PresentationDocument.Open(String path, Boolean isEditable, OpenSettings openSettings)
   at DocumentFormat.OpenXml.Packaging.PresentationDocument.Open(String path, Boolean isEditable)
   at ReproOxml3dBug.Program.Main(String[] args)

Expected

Just the string "Opened successfully" written to standard output.

@tomjebo
Copy link
Collaborator

tomjebo commented Nov 15, 2021

Hi @andrewmolyneux, thanks for bringing this to our attention. Just to be thorough, can you provide the steps when you created this in PowerPoint? It looks like both forms of this content type are referenced by Office source so I want to make sure there isn't an ambiguity in Office.

@andrewmolyneux
Copy link
Author

No problem! FYI I'm using PowerPoint 2019, reporting itself as "Version 2110 (Build 14527.20276 Click-to-Run)".
I can't remember precisely what I did in PowerPoint to create the sample file, but I can reproduce the issue with a file created as follows:

  • Open PowerPoint
  • Click "New"
  • Click "Blank Presentation"
  • Select the "Insert" tab on the Ribbon
  • Click "3D Models" on the Ribbon (which invokes the "Online 3D Models" picker)
  • Click the "Emoji" category
  • Select any emoji you like (I selected the 14th one from the top left, counting left-to-right then top-to-bottom, but I very much doubt it matters which you pick)
  • Click the "Insert" button
  • Select the "File" tab on the Ribbon
  • Click "Save" and choose a location to save the file

Anecdotally, I've tried using the OXML SDK to open a few PPTX files containing 3D objects, from various sources, and I haven't seen one yet that worked. I might just have been unlucky though 😀

@tomjebo
Copy link
Collaborator

tomjebo commented Nov 15, 2021

@andrewmolyneux Yes, it looks like the correct MIME type should actually be model/gltf-binary based on standards but PowerPoint writes a '.' instead of a '-'. The references to '-' in the greater code are actually for the clipboard format (i.e. copying/pasting) in Office. I'll get the whole story but this will likely be an easy fix.

@andrewmolyneux
Copy link
Author

Thanks Tom! I hope it will be an easy fix so I can finally update my app to use a reasonably recent version 😄

@sergey-tihon
Copy link

It is definitely an issues introduced in 2.14.0 and it worked as expected in 2.13.1.

I've upgraded DocumentFormat.OpenXml from 2.13.1 to 2.14 on our QA word processing node.
Not it fails daily to open about 300 documents per day (all with *.glb files inside)

image

@tomjebo
Copy link
Collaborator

tomjebo commented Nov 19, 2021

I'm testing the fix. Will submit the PR asap.

@tomjebo
Copy link
Collaborator

tomjebo commented Nov 19, 2021

PR #1075 submitted, @sergey-tihon @andrewmolyneux can you give this a test and verify that it resolves this issue for you?

@sergey-tihon
Copy link

@tomjebo is there an easy way get binaries from CI to we need to build from source?

@tomjebo
Copy link
Collaborator

tomjebo commented Nov 20, 2021

@sergey-tihon until the PR is merged, you will have to use the source branch (my branch in this case) to test. Once merged, you can pick up a CI build (see the README).

@tomjebo
Copy link
Collaborator

tomjebo commented Nov 24, 2021

@sergey-tihon PR #1069 has been reworked. it should be the same result but you might want to retest your scenario to verify. I tested with your original repro file.

@twsouthwick
Copy link
Member

This should be in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants