From 2c99f0eb3d071eae5866f2d5d5a112de0f1c7f5e Mon Sep 17 00:00:00 2001 From: yflau Date: Sun, 28 Apr 2013 11:34:11 +0800 Subject: [PATCH 1/3] Update docx.py --- docx.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docx.py b/docx.py index 3ab37bb..4f3570e 100755 --- a/docx.py +++ b/docx.py @@ -400,7 +400,7 @@ def table(contents, heading=True, colw=None, cwunit='dxa', tblw=0, twunit='auto' return table -def picture(relationshiplist, picname, picdescription, pixelwidth=None, pixelheight=None, nochangeaspect=True, nochangearrowheads=True): +def picture(relationshiplist, picname, picdescription, pixelwidth=None, pixelheight=None, nochangeaspect=True, nochangearrowheads=True, jc='left'): '''Take a relationshiplist, picture file name, and return a paragraph containing the image and an updated relationshiplist''' # http://openxmldeveloper.org/articles/462.aspx @@ -501,6 +501,10 @@ def picture(relationshiplist, picname, picdescription, pixelwidth=None, pixelhei run = makeelement('r') run.append(drawing) paragraph = makeelement('p') + pPr = makeelement('pPr') + pJc = makeelement('jc', attributes={'val': jc}) + pPr.append(pJc) + paragraph.append(pPr) paragraph.append(run) return relationshiplist, paragraph From 843c1d43b8de915b40c88a4d32b5106e1560c560 Mon Sep 17 00:00:00 2001 From: yflau Date: Sun, 28 Apr 2013 12:46:12 +0800 Subject: [PATCH 2/3] Update docx.py --- docx.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docx.py b/docx.py index 4f3570e..83d56b5 100755 --- a/docx.py +++ b/docx.py @@ -266,7 +266,7 @@ def heading(headingtext, headinglevel, lang='en'): return paragraph -def table(contents, heading=True, colw=None, cwunit='dxa', tblw=0, twunit='auto', borders={}, celstyle=None): +def table(contents, heading=True, colw=None, cwunit='dxa', tblw=0, twunit='auto', borders={}, celstyle=None, jc='left'): """ Return a table element based on specified parameters @@ -312,6 +312,8 @@ def table(contents, heading=True, colw=None, cwunit='dxa', tblw=0, twunit='auto' tableprops.append(tablestyle) tablewidth = makeelement('tblW', attributes={'w': str(tblw), 'type': str(twunit)}) tableprops.append(tablewidth) + pJc = makeelement('jc', attributes={'val': jc}) + tableprops.append(pJc) if len(borders.keys()): tableborders = makeelement('tblBorders') for b in ['top', 'left', 'bottom', 'right', 'insideH', 'insideV']: From 14ec2ae44c9c055e54e8a49d2d4c2348c53a3554 Mon Sep 17 00:00:00 2001 From: Felix Liu Date: Fri, 28 Jun 2013 15:33:21 +0800 Subject: [PATCH 3/3] modify os.mkdir to os.makedirs --- docx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docx.py b/docx.py index 83d56b5..ad98766 100755 --- a/docx.py +++ b/docx.py @@ -411,7 +411,7 @@ def picture(relationshiplist, picname, picdescription, pixelwidth=None, pixelhei # Copy the file into the media dir media_dir = join(template_dir, 'word', 'media') if not os.path.isdir(media_dir): - os.mkdir(media_dir) + os.makedirs(media_dir) shutil.copyfile(picname, join(media_dir, picname)) # Check if the user has specified a size