Edit Word documents but keep original formatting
Project description
Mass Edit Word Documents But Keep Original Formatting
Edit existing Word documents effortlessly and without changing the original formatting of the document.
As great as the original docx library is, this "keep same format" feature is not natively supported. However, this functionality is pretty useful if you want to automate document writing or editing and need to adhere to strict formatting rules. Hence, I wrote this small add-on module.
Installing
With pip: pip install docxedit
Dependencies
Included as a dependency: python-docx
Functions
Most of the functions in this module work primarily with runs, which are sequences of strings with the same formatting style. This is how we can edit the document but keep the original format.
Example Usage
from docx import Document
import docxedit
document = Document()
# Replace all instances of the word 'Hello' in the document by 'Goodbye'
docxedit.replace_string(document, old_string='Hello', new_string='Goodbye')
# Replace all instances of the word 'Hello' in the document by 'Goodbye' but only
# up to paragraph 10
docxedit.replace_string_up_to_paragraph(document, old_string='Hello', new_string='Goodbye',
paragraph_number=10)
# Remove any line that contains the word 'Hello' along with the next 5 lines
docxedit.remove_lines(document, first_line='Hello', number_of_lines=5)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docxedit-1.0.1.tar.gz.
File metadata
- Download URL: docxedit-1.0.1.tar.gz
- Upload date:
- Size: 6.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ad000b724c3a34f968c07ed5ca68c469ce8c890e2fc07d8bb203ddb60157b14
|
|
| MD5 |
b2b8f1b9c992a3b07d1533048cea549b
|
|
| BLAKE2b-256 |
f0a2e1f6976c8542a74590baa9a7dbcf40c2a765e2a585ec3ec8fc87416b5429
|
File details
Details for the file docxedit-1.0.1-py3-none-any.whl.
File metadata
- Download URL: docxedit-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dcdcae7530deb7473b66368cecfe5eda8b891c7e6ac4d5bd3c257d8cb5906d8
|
|
| MD5 |
9a541295c579947c9b222d827ebcf909
|
|
| BLAKE2b-256 |
dd5a0bf51e6ce29b0bc15a0e652c776d84a6ee12cb356896643aaae8d12e6007
|