1,477 questions
0
votes
0
answers
9
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 ...
0
votes
0
answers
12
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 ...
0
votes
0
answers
43
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....
0
votes
1
answer
20
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.
0
votes
0
answers
17
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 ...
0
votes
0
answers
20
views
python-docx: get document default font properties
I am writing a program which will read from a docx file and output formatted game code. Therefore, I need to gather all information I can from the docx document so I can design my program effectively. ...
1
vote
0
answers
45
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 ...
0
votes
0
answers
18
views
Deleting images and tables that aren't under an specific Heading with python-docx
I have to change a lot of docx documents. I need to strip some content and only leave the relevant one.
All docx files have the same structure, I need to keep text, images and tables under certain ...
0
votes
0
answers
43
views
Convert word document to pdf with clickable links
I have the following code that converts a word document named LG_LINKS.docx to pdf with clickable links. The code is working but the links not accurate. For example I have this link https://streamable....
-1
votes
1
answer
110
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 ...
0
votes
0
answers
47
views
how can i extract numbered lists,bullets and alignment of content if docx file using python docx
I can extract the contents of a DOCX file using Python's python-docx, and I am generating an HTML file from the extracted content. However, I'm struggling to ensure that the contents are properly ...
0
votes
0
answers
15
views
How can I fetch the title and start page number from the table of content?
I have this file created in MS-Word. I wanted to get the start page number and the title from the table of content.
But I could only grab the Title, and got stuck on how to fetch the start page number....
0
votes
1
answer
42
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 ...
0
votes
1
answer
61
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(...
1
vote
1
answer
70
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. ...
0
votes
0
answers
31
views
Convert HTML to WordML with CSS styling
I have DOCX templates with placeholders enclosed in curly brackets (e.g., {goals}, {objective}, {summary} and etc ). Using LLM API, I generate text to replace these placeholders, with the output in ...
0
votes
2
answers
75
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 ...
1
vote
0
answers
43
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 ...
0
votes
1
answer
65
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 ...
0
votes
1
answer
35
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....
0
votes
1
answer
52
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 ...
0
votes
0
answers
81
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 ...
0
votes
1
answer
129
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 ...
0
votes
1
answer
43
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 ...
0
votes
0
answers
51
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 ...
0
votes
0
answers
52
views
doc2docx docx2pdf back to back
I'm trying to convert .doc files to .docx or .pdf.
def file_handler(input_path, output_path=None):
file_root, file_type = os.path.splitext(input_path)
file_name = os.path.basename(file_root)
...
0
votes
1
answer
69
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 ...
1
vote
2
answers
121
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 ...
0
votes
0
answers
45
views
Docx file converted from PDF file cannot be opened by online version of Microsoft 365
I used pdf2docx library to converte a 2 page document to word. The document has few graphics, a company logo and text boxes. The final docx document is readable by note pad(minor loss of formatting), ...
0
votes
1
answer
102
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
*...
1
vote
1
answer
43
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 = ...
1
vote
1
answer
60
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. ...
0
votes
1
answer
57
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 "...
-1
votes
0
answers
53
views
In python-docx, how can I extract all images, especially including floating images in the doc?
I wrote a py file that can extract all the images from a docx and save them in one folder. I found that it is effective for embedded images, but cannot recognize floating images.
I found that the ...
0
votes
0
answers
15
views
Python Docx: Inserting Dataframe Values into Table
enter image description here
I am trying to insert a table into the document using values from the DF to populate the table cells. I have 2 columns in the DF that are of interest: Operators and Titer
...
1
vote
2
answers
68
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 ...
0
votes
2
answers
52
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 ...
1
vote
1
answer
36
views
How do create a new line break in python-doxc that has a specified character size?
I currently have a paragraph as a header that is Pt48 in size and I want to create a new line break using add_break() which works perfectly fine but it inherits the top paragraph character size. Is ...
1
vote
1
answer
100
views
What are methods of parsing complex unstructured text from docx file into pandas?
I have a docx file with unstructured text that looks like the following:
docx File
Prep
Northern Kitchen Number One K01-24-01-P01 $132,500
Background:
None
Project Description:
Some long ...
0
votes
0
answers
47
views
Python-Docx Table Row Border limit?
I'm having an issue with Table Row borders. All seems to be working great up to rows 250-260 in all tables. Although my script indicates the task is getting done, the output shows no borders after ...
0
votes
0
answers
53
views
Setting image with proper margins due to header using python-docx
My task is to automate the formatting of a document according to the user's input. I had to add cover and back page images with smaller margins than the rest of the document. I figured out how to add ...
0
votes
1
answer
89
views
Make the contents of a table in the header and/or footer RTL using Python docx library
I've got a word document that has an empty 1 by 3 table (or a table with any dimension for that matter) in the header.
I want to be able to manipulate the cells of the table using python-docx library. ...
0
votes
1
answer
176
views
How can I use styles from an existing docx file in my new document?
I have a beautiful .docx file generated by a teammate and I would like to use the styles in it as defaults for the new documents I am generating programmatically via python-docx.
I am able to load the ...
1
vote
1
answer
137
views
How to use Python-Docx to extract the paragraphs in between a heading and a table
I am using Python-docx to work with several large word documents to extract headings, paragraphs and table contents and put them into Excel. The code is working well EXCEPT when there are multiple ...
0
votes
1
answer
76
views
pyinstaller won't package python-docx
Goal
I want to package a simple python app (let's call it wordy), that creates a basic word document using the python-docx libary, into a single .exe file.
setup
PyCharm project with poetry as the ...
1
vote
1
answer
75
views
Accessing shapes and textboxes in python-docx
This code can't seem to access text inside shapes, is there a way to do so?
from docx import Document
doc = Document('template.docx')
replace_word = {'Captain': 'Gerard B. Geronimo'}
for word in ...
1
vote
1
answer
353
views
python-docx restart list numbering
I am using python-docx and I am able to generate number lists. How do I have the numbers restart for those lists?
I want the lists to look like this.
List 1
List 1 Item 1
List 1 Item 2
List 1 Item 3
...
1
vote
0
answers
27
views
Issue with changing fonts for different styles using python-docx
I am trying to change font styling of a document as per the user's input preferences. Eg, if a user inputs to use font Bell MT for style Normal, Helvetica for Heading 1, Bahnschrift for Heading 2 etc ...
0
votes
0
answers
35
views
How to upload images using document.add_picture with autofit feature in a word file with python docx?
I've a working code which adds required images, applies border to it, saves it in a word file and then converts in a pdf file.
The problem here is that when I open the PDF in adobe acrobat, Some ...
0
votes
0
answers
21
views
How to add a docx file to a session in flask
I cannot add my docx file to my flask session, when I try and access the file later on there is nothing in the session.
document = Document('mydocument.docx')
session['documentsession'] = document
...