Skip to content
This repository has been archived by the owner on Jan 12, 2018. It is now read-only.

Updated example-makedocument.py to work with imagefiledict #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions example-makedocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)