@@ -365,22 +365,21 @@ def docproperties(title,subject,creator,keywords,lastmodifiedby=None):
365365 #attributes={'type':'dcterms:W3CDTF'},tagtext='2010-01-01T21:07:00Z',attributenamespace='xsi'))
366366 return docprops
367367
368-
369-
370- def savedocx (document ,properties ,contenttypes ,docxfilename ):
368+ def websettings ():
369+ '''Generate websettings'''
370+ web = makeelement ('webSettings' )
371+ web .append (makeelement ('allowPNG' ))
372+ web .append (makeelement ('doNotSaveAsSingleFile' ))
373+ return web
374+
375+ def savedocx (document ,properties ,contenttypes ,websettings ,docxfilename ):
371376 '''Save a modified document'''
372377 docxfile = zipfile .ZipFile (docxfilename ,mode = 'w' )
373- # Write our generated document
374- documentstring = etree .tostring (document , pretty_print = True )
375- docxfile .writestr ('word/document.xml' ,documentstring )
376- # And it's properties
377- propertiesstring = etree .tostring (properties , pretty_print = True )
378- docxfile .writestr ('docProps/core.xml' ,propertiesstring )
379- # And it's content types
380- contenttypesstring = etree .tostring (contenttypes , pretty_print = True )
381- print contenttypesstring
382- docxfile .writestr ('[Content_Types].xml' ,contenttypesstring )
383-
378+ # Serialize our trees into out zip file
379+ treesandfiles = {document :'word/document.xml' ,properties :'docProps/core.xml' ,contenttypes :'[Content_Types].xml' ,websettings :'word/webSettings.xml' }
380+ for tree in treesandfiles :
381+ treestring = etree .tostring (tree , pretty_print = True )
382+ docxfile .writestr (treesandfiles [tree ],treestring )
384383
385384 # Add & compress support files
386385 for dirpath ,dirnames ,filenames in os .walk ('template' ):
0 commit comments