1

I've been trying to input a series of pictures onto every slide on a powerpoint presentation. I type in the image path, and the relevant dimensions, but I get an error which I don't understand.

    for k in xrange(0, len(prs.slides)):
        img_path = os_path + str(k+1) + '.png'
        left = Cm(1.21)
        top = Cm(4.72)
        width = Cm(5)
        height = Cm(5)
        pic = prs.slides[k].shapes.add_picture(img_path, left, top, width, height)

This error then appears:

  File "src/lxml/parser.pxi", line 1819, in lxml.etree._parseMemoryDocument (src\lxml\lxml.etree.c:116494)
  File "src/lxml/parser.pxi", line 1700, in lxml.etree._parseDoc (src\lxml\lxml.etree.c:115040)
  File "src/lxml/parser.pxi", line 1040, in lxml.etree._BaseParser._parseUnicodeDoc (src\lxml\lxml.etree.c:109165)
  File "src/lxml/parser.pxi", line 573, in lxml.etree._ParserContext._handleParseResultDoc (src\lxml\lxml.etree.c:103404)
  File "src/lxml/parser.pxi", line 683, in lxml.etree._handleParseResult (src\lxml\lxml.etree.c:105058)
  File "src/lxml/parser.pxi", line 613, in lxml.etree._raiseParseError (src\lxml\lxml.etree.c:103967)
  lxml.etree.XMLSyntaxError: EntityRef: expecting ';', line 3, column 31

There is definitely a file that corresponds to the img_path, so I'm not sure what else is wrong

1 Answer 1

1

I think I fixed this.

My img_path in my documents included an & in the file name - I changed where the image was located (to a folder without an &) and it worked.

Sign up to request clarification or add additional context in comments.

1 Comment

Good catch Tom. This is probably something that should be fixed. The filename (where available) is included in the image information and written to the XML. I expect the name is not being escaped before writing. If you add an issue on the python-pptx GitHub issues list we'll get this fixed up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.