Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Filter by
Sorted by
Tagged with
0 votes
0 answers
26 views

How to perform multiple "render()" calls with docxtpl without losing unresolved variables?

I’m trying to fill a .docx template using the docxtpl library in Python, but I need to do it in multiple steps, because I can’t load the entire context dictionary into memory at once. The problem is ...
MathW166's user avatar
1 vote
0 answers
75 views

Missing spaces between words when parsing with python-docx

python-docx has a very simple object model: Document -* Paragraph -* Run, and is very easy to work with. However there's one showstopper issue: in some cases consequent runs (e.g. single words) do not ...
andy's user avatar
  • 23
0 votes
0 answers
118 views

Word bullets and numbering using Python

I'm writing a code that transforms a Word document into a different format. Well, I've made the rest of the changes, but I'm having a problem with the numbering and bullets. I'd like to keep them. I'...
ZXDe's user avatar
  • 1
0 votes
0 answers
72 views

Setting font size for text and tables using styles approach with python-docx library

I am using the python-docx library to create a docx file that contains text and a table right after it. I want to set the text size to 12 and table size to 9 point using styles. But the size of all ...
Comrade Che's user avatar
0 votes
1 answer
93 views

Using `python-docx`, extract all tables from a specific section of a Word Document

I have the following Word File (test_doc.docx) containing multiple sections and tables. I am only interested in capturing tables from Section 2 — Here's a markdown representation of it: Section 1 ...
corentin ducloux's user avatar
1 vote
1 answer
51 views

How fetch image address of word document?

I need to fetch the images adress in word document along with text and tables. Using doc.element.body loop I can't get image recognise, using doc.part.rels.values loop I can only get images. If ...
user30342609's user avatar
-1 votes
1 answer
107 views

Word to excel using python but preserve word format (bullet points) and structure

Script to convert word documents to excel. Works well but fails to keep structure and certain characters like bullet points. import tkinter as tk from tkinter import filedialog import re import os ...
Nick's user avatar
  • 927
0 votes
2 answers
85 views

python-docx header set anchor "to page"

Problem: put a logo image at top left position of the page. I've tried the following to accomplish the same but it doesn't work as expected: from docx import Document from docx.shared import Mm, Pt ...
user2239318's user avatar
  • 2,826
0 votes
1 answer
92 views

How to preserve text styles (bold/italic) and extract footnotes from a Word document using Python?

I’m working on a Python script to extract content from a Word document (.docx) and insert it into a SQL Server database. The challenge is that I need to preserve text styles like bold and italic, as ...
Zahra's user avatar
  • 119
0 votes
1 answer
62 views

Changes to table with python-docx not persistent in Python 3.11

I'm using python-docx (v1.1.2) and Python 3.11.3 to work on a tool to fix a bunch of Word documents automatically. I've been able to update fonts, titles, texts, headers and footers and tables (their ...
J. Maria's user avatar
  • 436
0 votes
0 answers
41 views

Python-docx: How to force a new page when adding tables with images?

I'm generating a Word document using python-docx that contains images arranged in a table format. The document should: Fit multiple images per page (e.g., 4x4 for word cards). Ensure proper page ...
Superchitah's user avatar
0 votes
1 answer
147 views

AttributeError: 'list' object has no attribute 'items'

I have been trying to write a tool to look at Word documents in a specified path for broken links. I gave up on having it search a folder, thinking I just need to get it to do a document first. With ...
Travis Webb's user avatar
0 votes
0 answers
49 views

Table of Contents of List of Figures and Tables are not clickable in PDF while converting docx to pdf using libreoffice writer

I am using pythn-docx(https://github.com/python-openxml/python-docx) to generate a docx file and then converting this docx file into PDF format using unoconv (https://github.com/unoconv/unoconv), ...
Rajan Singh's user avatar
0 votes
0 answers
35 views

.add_run().add_picture() not adding picture

I have this code that trying to generate a word document. I have the document working except the image adding. When I try to add a run, the image doesn't show up. When I try to add a picture to the ...
Hayden Dudley's user avatar
0 votes
0 answers
22 views

Group Textboxes using XML in Word

Is there a way to group textboxes using XML. I have tried using <v:group> as can be seen below but this doesn't seem to work? Ideally I'd like the group to inherit the size of the textbox. <v:...
Brad's user avatar
  • 117
0 votes
1 answer
104 views

How to properly structure and clean extracted text from DOCX in Python?

I am working on a Flask-based web application that processes multilingual agenda documents. The documents are in DOC/DOCX format and contain structured agenda items that I need to extract and format ...
Binal Dalia's user avatar
0 votes
0 answers
159 views

How to edit/change every hyperlink in a word document with python-docx or some other library?

I have been trying to re-link a .docx file that contains many hyperlinks embedded inside text sections since we decided to change document storage services. So the links on the docx are old and need ...
Picucu's user avatar
  • 11
0 votes
0 answers
40 views

Is it possible to output a word document from a sagemaker pipeline processing step?

I have a sagemaker pipeline where I output a summary of clustering data in a chart in a csv file. I am trying to update my pipeline to export the chart in a word document instead. Using the python ...
anishabm's user avatar
0 votes
0 answers
22 views

Resize slides from pptx in a generated docx using python libraries

I have a document in docx format generated from a pptx containing slides. I want to resize the slides in the pages of the docx by automation using python libraries. I tried with python-docx and aspose ...
Rémi M's user avatar
0 votes
0 answers
50 views

Module not found error with docx and pandas, no output with VSCode and Terminal

I'm using Docx and Pandas to create a program that copies data from an Excel sheet to a Word document. I've been running into some errors in VSCode, where I am either thrown a ModuleNotFound error ...
SG0d11's user avatar
  • 21
0 votes
1 answer
51 views

Manually Copying Chart from Docx to Another Results in Corrupted File

I'm working on a requirement to copy content from a docx file and append it to another, but the mess starts when it comes to charts. I'm using python-docx, and since it does not support charts ...
tnhmcm's user avatar
  • 11
0 votes
1 answer
90 views

how to set color to value in python-docx table?

Using python-docx my code produces a Word file. In this file I make a table. First kolom is named: onderwerp. Values in this column are subjects. The names of the other columns are the 12 months. In ...
JanP's user avatar
  • 1
0 votes
0 answers
32 views

Inserting a table into a known table with docx

Good day all, I'm working on a very specific automation which requires a table being added into an existing table. So far I can replace key words in a dictionary. However, I also want to be able to ...
Joseph Joe Soltan's user avatar
0 votes
0 answers
42 views

Is there a way to create multiple list style, use either one when needed?

Figured out how to define multiple list styles but when trying to use them it always defaults to the last defined list style. For example, I defined bullet list with numID X and then numbered list ...
Raj Patel's user avatar
0 votes
0 answers
18 views

Format page in in docx on page where specific paragraph is placed (python docx)

I need to apply below function in document on specific page. Function purpose is to set up specific style and margins settings. I mark this page with paragraph (see screenshot). How I can identify ...
user14566555's user avatar
0 votes
0 answers
250 views

Adding valid comments to docx documents using python

Using python-docx, it is impossible to directly create a comment in a Word Document, that is why this function was created : from datetime import datetime from typing import List from xml.etree....
Smorg's user avatar
  • 89
0 votes
1 answer
47 views

Accessing Headers and Footers with python-docx

Is it possible to change a word in a word files Header and Footer using python-docx. Like i would place a {{PLACEHOLDER_TEXT}} and change it to an actual word.
John Wilmer Dela Cerna's user avatar
0 votes
0 answers
28 views

Python + Comtypes app compatibilityt errors

I created a project that used CustomTkinter, Python, Multiprocessing, comtypes, python-docx and more. The project lets the user enter information of an individual stored in a sqilte database and can ...
John Wilmer Dela Cerna's user avatar
1 vote
0 answers
62 views

How find information in adjacent cells merge cell docx document with Python

I'm using the python-docx library to extract data from a MS Word document. More precisely, I'm trying to find and merge cells in tables, extract the content of the found cell, and register it as the ...
profpow's user avatar
  • 35
-1 votes
1 answer
256 views

How to convert html to docx for a table with nested tables?

I want to convert any html with a table that has nested tables in its cells. When I try to do this, additional rows appear after the rows in which the nested tables were located. The number of rows ...
Василий Чернов's user avatar
0 votes
1 answer
100 views

I manually installed the Python docx library in my script folder but I can't import it?

For admin reasons I can't edit the PATH variable so I couldn't use pip to install my PyPi and 3rd party libraries/modules, so I worked around it and I installed their source code using the official ...
Giorgio Doveri's user avatar
0 votes
1 answer
120 views

How to combine multiple docx files into a single in python

I combined multiple text files into a single text file using simple code: with open("Combined_file.txt", 'w') as f1: for indx1, fil1 in enumerate(files_to_combine): with open(...
ewr3243's user avatar
  • 441
1 vote
1 answer
101 views

How to turn off cell spacing in a Word document using python docx? (or any other package)

I have an input word document that has some tables with cell spacing set to 0.02". I’d like to turn off that cell spacing (or set it to 0) with the code below that uses the python-docx package. ...
Semihcan Doken's user avatar
0 votes
2 answers
98 views

How to insert a title at the beginning of an edited document?

I have a bunch of existing documents. Problem: they have no title. My idea is to open every document and add the (modified) filename as a title. I can't find a way to insert a title at the beginning ...
PeterP's user avatar
  • 3
1 vote
0 answers
89 views

preserve numbered list index using python-docs and docx2python

I am working on a python3 script that converts a word docx to a html file. When converting numbered lists, I am having difficulty preserving the original number in a numbered list. I have attached an ...
Harris Charalambous's user avatar
0 votes
1 answer
113 views

Replacing a string in a docx by a hyperlink using Python and the run concept while maintaining original font style and size

I have a Python script which aims to parse a docx Doc to replace codes (which may be unintentionally wrongly written) by text with a hyperlink. I already have the raw and cleaned values from the ...
mug8's user avatar
  • 1
0 votes
1 answer
71 views

python docx processing encouunter ValueError: WD_COLOR_INDEX has no XML mapping for 'none'

I have google this error and find no-one else encounter this ValueError before. You could see from the traceback log below that the error is triggered by my code line bg_color = run.font....
Allan Ruin's user avatar
  • 5,297
0 votes
1 answer
70 views

How do I add a paragraph with add_run() before table with python docx?

I have a table with a line at the top of the document. I need to replace that with just the line inside that table and make the line bold as well. I am able to insert a line with add_paragraph and ...
Nikita Sarode's user avatar
0 votes
0 answers
196 views

Capturing Formatted Numbering from DOCX Files in Python

I'm working on a Python project where I need to extract text from DOCX files, preserving the formatted numbering. I've encountered a peculiar issue that I'm hoping someone can help me solve. The ...
Anshuman Sharma's user avatar
0 votes
1 answer
678 views

How create a multilevel numeric list using Python-Docx that also works on Google Docs?

My goal is to create a nested numeric list using python-docx and upload to Google Docs. For the present moment, I could handle the level 0 lists and works fine, the problem starts when there is more ...
dfop02's user avatar
  • 133
0 votes
1 answer
68 views

How to read and input data into a table graph in an template word file using python docx

I have a docx file with table graph which can not recognized by doc.tables. Here is the file: https://github.com/python-openxml/python-docx/files/1867861/non_readable_table.docx Same issue was ...
xie186's user avatar
  • 509
0 votes
0 answers
58 views

How to use python to extract the images in ppt

Since many of the pictures in the PPT are mostly in the form of combinations, I need to output the combined image form and extract it into the document. If it is to convert PPT to PDF, can it solve ...
user23640279's user avatar
0 votes
1 answer
126 views

How to Convert docx to pdf with special characters like tick marks and cross mark in linux

I am working on my project, where I come across a problem when I am trying to convert my docs document to pdf. When I am trying to convert docs into pdf in linux special character convert in different ...
Kskrishna's user avatar
1 vote
2 answers
278 views

Multiple Numbered Lists with python-docx

I need to generate lots of similar one-page content in a single docx file for personal purposes, so I have created a Python script to automate that. Some of this content is a numbered list, but ...
Glenn's user avatar
  • 185
0 votes
1 answer
208 views

Python-Docx replacing texts with tables

I am currently confused on how to insert a table in the middle of a document, like is it possible to change a text placeholder into a table in python? For example: *** PARAGRAPH **** TEXT_PLACEHOLDER *...
John Wilmer Dela Cerna's user avatar
0 votes
1 answer
92 views

Is there a way to suround a text with borders and perhaps define the weight of those borders with Python Docx?

i am working on creating a word file with Docx Python, and at some point I need to surround a specific text or word in a paragraph with borders. p6 = document.add_paragraph() p6.alignment = ...
babeni nelson's user avatar
1 vote
1 answer
76 views

How to Ensure Consistent Spacing Before Each Paragraph in a Word Document Using Python?

I am trying to generate a Word document where each word is on a separate page and has a specific amount of spacing before the paragraph. I am using the python-docx library to create the Word document. ...
Rashid mehmood's user avatar
0 votes
1 answer
96 views

Python Docx: change name of font in w:cs? Converting font-encoding to Unicode

Some writing systems (scripts) have been represented in "hacked fonts" by changing the glyphs of characters in ASCII or Arabic or other ranges. For example, the shape of the glyph for "...
Sven Oly's user avatar
0 votes
2 answers
129 views

How to put two images, left and right aligned in header in a word file (.docx) Python

I want to put two logo images in the header of the document. One logo should stay at the very left and the other at the very right of the word file. Below is my code, but this sets both logos on the ...
Amisha Saha's user avatar
0 votes
2 answers
61 views

In Python-docx, how to determine the index of the previous paragraph of a table?

I want to extract all the tables in a document, process them, and then paste the new tables and the text of the document into another document in the original order. But in Python-docx, paragraphs and ...
Sword Lina's user avatar

1
2 3 4 5
29