Questions tagged [docxtpl]

python module built on top of python-docx to use docx documents as jinja2 templates

python module built on top of to use docx documents as templates

website: https://pypi.org/project/docxtpl/

57 questions
3
votes
2 answers

Render simple HTML into docx using docxtpl

I'm using python module docxtpl to print data inside a docx template written with jinja2. Works great so far but i need to render in the docx some simple HTML like this:

Some title

Lorem ipsum dolor sit amet,…

Mario
  • 131
  • 1
  • 12
2
votes
0 answers

How populate this complex table with python docx template?

Well, I continue to use the python-docx-template. I was making the template for some tables, specifically this one: The result table that I'm looking for is this (leaving aside the date/fecha): The original idea was the table will receive data…
DeivDev97
  • 21
  • 5
2
votes
1 answer

docxtpl special tr tag {%tr %} is not working

Hi i am using docxtpl to generate the MS Word documents from python using JINJA template engine, I checked this documentation which says we can use special tags for table rows, columns and paragraphs but i am not able to generate table rows…
Zain Ul Abidin
  • 2,467
  • 1
  • 17
  • 29
2
votes
1 answer

docxtpl Formatting lost when using subdoc()

I have a DOCX template and I want to insert a sub document into it using the {{p }} tag, it works fine for now except that some formattings are lost. In the original document (sub_doc.docx), the title of the table is italic, centered, the size of…
Oussama He
  • 555
  • 1
  • 10
  • 31
2
votes
0 answers

Python docxtpl - How to change the size of the column?

I am using docxtpl to generate word documents. I am inserting multiple tables to a Word document and wondering how I can change the size of the specific column in the code. Here is the table in my template.docx: The table looks in the report like…
Nil
  • 201
  • 3
  • 12
1
vote
1 answer

Creating a Word table using docxtpl and jinja2

I have the following dictionary of dictionaries: { "col_labels": [ "Naam", "Discipline", "Rol", "Bedrijf" ], "project_disciplines_final": [ { "dict_1": [ "Marcel", …
Luc
  • 35
  • 5
1
vote
0 answers

How can i write multile lines in one cell of table with docxtpl?

How can I write multiple lines in one cell of a table with docxtpl? I have searched some articles, but they almost doing it with coding. Can this be achieved by just fixing the docx template? Here is my simple Python code for reading the template…
1
vote
0 answers

Doctxpl doesnt create a new save document

While the code runs without issues, I cannot locate the "perro.docx" document (the one with the replaceable variables). It's not in the same folder as my Python file and document template. Additionally, I sometimes encounter an error that states the…
A cp
  • 11
  • 2
1
vote
1 answer

python-docx-template: Construct Word table in python and place into a specific location in a Word template

I wish to construct a Microsoft Word table using Python and then place it into a location marked by a placeholder in the Word template. Is this possible to do using docx and docx template? The code below is a basic example of what I'm trying to do,…
Greenjoy
  • 59
  • 2
  • 12
1
vote
0 answers

Switch PDF file according to value in DataFrame column using Python and DocxTemplate

I have an Excel file with a list of clients, including their name, document number, credit card number, and company. For each client, I need to create a PDF file with the values from the table. First, I transform some values in the table, then…
1
vote
1 answer

(Docxtpl) How to add conditional statement to a value in a existing template

I would like to seek your help on my below issue. I have been struggling with this issue for a few days. I have a word template as shown below in docx. =============== Name: {{ Personal_name }} Age:{{ Personal_Age }} Teenager/Adult: {% if…
Tony Tang
  • 47
  • 6
1
vote
0 answers

How can I render HTML-file content to specific tag/word into a template.docx file (word replacement)?

How can I copy the content of an HTML file (data_1.html") to a specific location in a pre-made "template.docx" and then save it as "output.docx" with python? I know, that it is possible with this simple Code to convert html to docx perfectly…
1
vote
1 answer

Encountered error while trying to install package. lxml

work/Versions/3.9/Headers -c src/lxml/etree.c -o build/temp.macosx-10.9-universal2-cpython-39/src/lxml/etree.o -w -flat_namespace src/lxml/etree.c:96:10: fatal error: 'Python.h' file not found #include "Python.h" ^~~~~~~~~~ 1 error…
Lans
  • 11
  • 1
1
vote
1 answer

Docxtpl: Add heading level to text

How can I add a heading level to text with docxtpl? Can I do something like this: ? rt = RichText() rt.add('Headername', level=1)
Johs
  • 73
  • 1
  • 7
1
vote
1 answer

How to apply styling to docxtpl

I have created a template and I successfully write to variables like this: tpl = DocxTemplate(r"template.docx") context = ({"issue_date" : "16-Jan 2021", "na_us_guid_new": "1. 13-Jan-2021: abc"}) tpl.render(context) tpl.save(r"testing.docx") I…
template
  • 65
  • 4
1
2 3 4