Question

Add pictures to table in Word doc using Python docx in PythonCaller

  • 28 November 2022
  • 4 replies
  • 140 views

Userlevel 1
Badge +11

Recently I have been playing/fooling/struggling around with the creation and modification of Word documents using a combination of MSWordStylers and the Python docx library, called from a PythonCaller. A very instructive journey :-)

To make sure I don't forget immediately everything I've learned, I have decided to summarize my findings in a template. And because a lot of input has come from this community I will share the results here. Please see the zip file attached: images-to-table-python-docx.zip

It starts by reading Parcel information from a database (gpkg) and it creates a summary table in a word document, including a little image with the parcel plotted on an aerial image.

Inspiration has been taken from these to discussions:

With some slight modifications I have integrated these two examples in my own workflow.

What do you think?

Cheers,

Egge-Jan

 

Edit 2024-04-05: attachment added again in zip file format (apparently the new community environment does not support the uploading of fmwt files).


4 replies

Userlevel 6
Badge +33

Thanks for sharing. Personally, I don't like renaming transformers, as this makes it harder to review workspaces.

Badge +6

This post is just what I was looking for, but where is the template attached?

Userlevel 3
Badge +18

Hi @mathiku it probably got lost in translation going to the new community site

Best to report here I guess and hope someone at Safe can recover it

Userlevel 1
Badge +11

Hi @mathiku, Hi @becchr,

Thanks for letting me know that the attachment was gone… The original attachment was a Safe Software *.fmwt (Template) file. But apparently the new community environment does not support this file format anymore.

I have added the example again, both the workspace and an input geopackage, but in a zip file this time. See the original, edited post above.

@mathiku: please let me know if this works for you.

Cheers,

Egge-Jan

Reply