wordpress hit counter
Re: Generating OpenXML using Python and Django - Scripting Languages - Development Tools - OpenXML Developer

Re: Generating OpenXML using Python and Django

Development Tools

Discussions about working with Open XML using a wide range of development tools

Generating OpenXML using Python and Django

  • rated by 0 users
  • This post has 2 Replies |
  • 1 Follower
  • Hello all,

    I'm trying to generate a DOCX using python and I'm running into some encoding problems. Hopefully someone can offer some pointers as to where I may be going wrong.

    I've used the python web framework Django to create an application into which my users are entering data. The data is then rendered into XML, zipped up and shipped out as a DOCX.

    My current solution involves reading all of the component files from the server's disk and adding them to a zip file. I'm trying to replace this and pull all of the file information out of a database, without using flat files. This will let users make changes to the templates without requiring access to the server.

    I'm able to render the XML correctly and I can produce a zip file which can be opened by Winzip and unzip. When I try to open the file in Word, however, I get a "There was an error opening the file" message.

    What I would like to know is: what is the best way to diagnose this error? Are there any tools available for validating DOCXs?

    So far I've been lucky and have caught most errors by inspecting the XML. These all look fine for the current version, however.

    Also, is there a required encoding for the files or their names within the zip? At the moment they're being written as UTF-8 encoded strings with UTF-8 encoded filenames (XML files, that is. Others are still pulled from the disk).

    Thanks in advance for any pointers.

    Felix
  • Hi,

    I guess there may be some problem in relationship file or in content_type file, I am not sure. You can download a tool which can compare two docx files from http://diffopc.arstdesign.com/. Tool compares each xml file in the documents. This may help you in cracking the issue.

    Sandeep

     

  • Hi Sandeep,

    Thanks for the pointers. It was relationship problem in the end (took a while to track down). I'll have a look at the link you've posted.

    Cheers,

    Felix
Page 1 of 1 (3 items)