After trying for 30 hours+ to implement python_-docx
and docxtpl
for certain functionalities (and rigulariously failing), I decided to come here for advice.
My current project exists of different pictures (.png), formatted texts (i.e. bold, shadow, font, color and so forth), etc. - now these elements need to be arranged / fit into a neat template. First, I tried pillow
by creating a canvas and adding all these elements each. The solution itself is extremely prone to errors and doesn't support all the functionalities as far as text is concerned. Next off, I went by creating a .docx
template (arranging pictures, text including font, style, etc.) and implementing the values this way - that worked! ... except of it not supporting more than one picture / media element per Word page!)
For demonstration purposes I tried to sketch the workflow:
Now it should be obvious why I tried Word - an easy-to-go word editing program in which I was able to format everything to my wishes (though the Python API didn't work, hence it's useless) - for demonstration purposes, here is a snippet of pseudo code:
#PSEUDO CODE
from docxtpl import DocxTemplate
tpl = DocxTemplate('file.docx')
tpl.replace_media('dummy.png', 'pic1.png')
tpl.replace_media('dummy2.png', 'pic2.png')
tpl.save('out.docx')
Depending on the setup, it either replaces None, or both pictures with one of them. According to various StackOverflow questions and threads, more than one picture isn't possible! Therefore the word approach is rather useless.
Anyhow, I'm out of knowledge. Any suggestions on how to achieve such a workflow, i.e. having an easy editable layout in which I just need to parse certain values in and get a .docx
, .png
, .pdf
, whatever..