📝 DOCX Placeholder Filler (with Image and Embedded Excel Support)
Description
This Python tool automatically replaces placeholders in Microsoft Word .docx documents with text, images, or data from embedded Excel files. It's ideal for generating templates like contracts, certificates, reports, and dynamic documents.
✨ Features
- 🔤 Replace text placeholders in
.docxfiles - 🖼️ Insert images into Word using placeholders
- 📊 Modify embedded Excel files (
.xlsx) that used to generate plot, chart or anything else inside Word documents - 🧩 Supports placeholders inside textboxes
- 🧾 Detect unfilled placeholders
- ✅ Preserve existing comments in .docx documents
- 🧠 Smart parsing of complex or multiline placeholder structures
📦 Installation
pip install docxfill
🧱 Placeholder Format
| Type | Syntax Example | Replacement Type |
|---|---|---|
| Text | {{name}} |
String |
| Number | {{age}} |
Int / Float |
| Image | {{profile_picture}} |
Image path |
| Excel | {{invoice_total}} (in cell) |
Cell content |
🚀 Usage
1. Run execute()
from docxfill.fill import execute
result = execute(
file_path="template.docx", # Input .docx file
output_file_path="output.docx", # Output .docx file
text_content={"name": "John", "age": "30"},
image_content={"profile_picture": "images/photo.jpg"},
state_dir="./test_files" # Optional working directory
)
print(result)
2. Sample Output
{
"tool": "docx_fill_with_image",
"success": true,
"output_file_path": "output.docx",
"filled": {
"name": "John",
"age": "30",
"profile_picture": "images/photo.jpg"
},
"unfilled_placeholder": ["email", "address"]
}
🔍 Key Functions
| Function | Description |
|---|---|
replace_text_in_paragraph() |
Replace text in regular paragraphs |
replace_text_in_excel_sheet() |
Replace text inside Excel cells |
extract_and_modify_embedded_excel() |
Modify embedded .xlsx content |
find_inner_placeholders_in_docx() |
Find any unfilled placeholders |
execute() |
Main function to run all processes |
| ✅ Supports placeholder inside Word textboxes |
📁 Folder Structure Example
test_files/
├── template.docx
├── output.docx
└── images/
└── photo.jpg
⚠️ Notes
- Only supports
.docx(not.doc) - Embedded Excel files must be
.xlsxformat - Placeholders must follow the
{{placeholder}}format - Images must be valid paths (relative or absolute)
📄 License
MIT License — Free for personal and commercial use.
Metadata
Release files for docxfill 1.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| docxfill-1.0.7.tar.gz | 5.9 kB | With provenance | Details for docxfill-1.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| docxfill-1.0.7-py3-none-any.whl | Python 3 | none | any | Details for docxfill-1.0.7-py3-none-any.whl |
Total release size: 12.1 kB
Release files / docxfill-1.0.7.tar.gz
| Download URL | docxfill-1.0.7.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55d7702015d507de5890d3df74e0ca55530234f80bb4c8387bf5db9c97168335
|
|
BLAKE2b-256 checksum How to use checksums |
be415c163d424bd68de058cc7b144cf5185b7159525189aa85ec8ef809ddd943
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 9, 2025.
Transparency logRelease files / docxfill-1.0.7-py3-none-any.whl
| Download URL | docxfill-1.0.7-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14091f12cb54473d7b10fff88e003f9a31972f919c20739540fef0b0aaf2d43b
|
|
BLAKE2b-256 checksum How to use checksums |
c8f6a4a712105ffa17271127505770efe828266b12b289e25e0a231e65128cf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 9, 2025.
Transparency logSecurity for docxfill 1.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for docxfill-1.0.7.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 9, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.