python-pptx icon indicating copy to clipboard operation
python-pptx copied to clipboard

KeyError: "no content type 'application/x-fontdata' in pptx.spec.pml_parttypes"

Open mrpj100 opened this issue 13 years ago • 3 comments

I get the above error when opening a presentation. I'm guessing there's an embedded font that python-pptx can't cope with?

Traceback (most recent call last): File "ppt_helloworld.py", line 4, in prs = Presentation('sharp_template.pptx') File "/usr/local/lib/python2.6/dist-packages/pptx/api.py", line 29, in init self.package = _Package(file) File "/usr/local/lib/python2.6/dist-packages/pptx/presentation.py", line 93, in __init self.open(file) File "/usr/local/lib/python2.6/dist-packages/pptx/presentation.py", line 186, in __open pkg = pptx.packaging.Package().open(file) File "/usr/local/lib/python2.6/dist-packages/pptx/packaging.py", line 100, in open part._load(fs, partname, cti, parts_dict) File "/usr/local/lib/python2.6/dist-packages/pptx/packaging.py", line 256, in _load target_part._load(fs, target_partname, ct_dict, parts_dict) File "/usr/local/lib/python2.6/dist-packages/pptx/packaging.py", line 240, in _load self.typespec = PartTypeSpec(content_type) File "/usr/local/lib/python2.6/dist-packages/pptx/packaging.py", line 517, in __init raise KeyError(tmpl % content_type) KeyError: "no content type 'application/x-fontdata' in pptx.spec.pml_parttypes"

mrpj100 avatar Sep 10 '13 10:09 mrpj100

Hi mrpj, can you send a listing of the contents of the .pptx file? I need to see the "directory" structure.

On Mac/Linux the command is:

unzip -l sharp_template.pptx

and it outputs something like this:

Archive:  test.pptx
  Length     Date   Time    Name
 --------    ----   ----    ----
     3259  01-01-80 00:00   [Content_Types].xml
      738  01-01-80 00:00   _rels/.rels
      311  01-01-80 00:00   ppt/slides/_rels/slide1.xml.rels
     1138  01-01-80 00:00   ppt/_rels/presentation.xml.rels
               ...
      788  01-01-80 00:00   docProps/core.xml
     9395  01-01-80 00:00   ppt/printerSettings/printerSettings1.bin
 --------                   -------
    97530                   38 files

I need to see what files are in there for the application/x-fontdata content type.

It's quick to fix once I have that information.

scanny avatar Sep 10 '13 16:09 scanny

I was able to find what I needed. I pushed a fix for this to the develop branch with commit 67b498e. Will get to master with next release.

scanny avatar Sep 11 '13 05:09 scanny

Thanks very much!

mrpj100 avatar Sep 11 '13 07:09 mrpj100