From 197e84b234ed2153fce4ac768a9505dd8574b993 Mon Sep 17 00:00:00 2001 From: Jeffrey de Lange Date: Sat, 12 Apr 2014 12:44:40 +0200 Subject: [PATCH] Updated example-makedocument.py to work with imagefiledict --- example-makedocument.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/example-makedocument.py b/example-makedocument.py index dfc8c22..ceb40f9 100755 --- a/example-makedocument.py +++ b/example-makedocument.py @@ -19,6 +19,9 @@ # Make a new document tree - this is the main part of a Word document document = newdocument() + + # Make a dict in which you will store image data + imagefiledict = {} # This xpath location is where most interesting content lives body = document.xpath('/w:document/w:body', namespaces=nsprefixes)[0] @@ -68,7 +71,8 @@ # Add an image relationships, picpara = picture(relationships, 'image1.png', - 'This is a test description') + 'This is a test description', + imagefiledict=imagefiledict) body.append(picpara) # Search and replace @@ -109,5 +113,6 @@ # Save our document savedocx(document, coreprops, appprops, contenttypes, websettings, - wordrelationships, 'Welcome to the Python docx module.docx') + wordrelationships, 'Welcome to the Python docx module.docx', + imagefiledict=imagefiledict)