ONLYOFFICE Document Builder for Python
Python wrapper for ONLYOFFICE Document Builder — a framework that creates, edits and converts DOCX, XLSX, PPTX and PDF (including PDF forms) documents programmatically, without any office suite installed and without a running server.
The wheel is self-contained: it ships the native Document Builder engine
(doctrenderer, x2t and the required resources) next to the Python module, so
pip install is the only installation step. There are no Python dependencies.
Installation
pip install document-builder
Upgrade to a newer build:
python -m pip install document-builder --upgrade
Supported platforms
Binary wheels are published for:
| OS | Architectures | Wheel tag |
|---|---|---|
| Windows | x86-64, x86 | win_amd64, win32 |
| Linux | x86-64, ARM64 | manylinux_2_23_x86_64, manylinux_2_23_aarch64 |
| macOS | x86-64 (10.9+), ARM64 (11.0+) | macosx_10_9_x86_64, macosx_11_0_arm64 |
Wheels are tagged py2.py3, so the same file works on Python 2.7 and Python 3.x.
There is no source distribution — the package wraps prebuilt native binaries.
Quick start
Create a DOCX file with a single paragraph:
import os
import docbuilder
builder = docbuilder.CDocBuilder()
builder.CreateFile("docx")
context = builder.GetContext()
globalObj = context.GetGlobal()
api = globalObj["Api"]
document = api.GetDocument()
paragraph = api.CreateParagraph()
paragraph.AddText("Hello, World!")
content = context.CreateArray(1)
content[0] = paragraph
document.InsertContent(content)
builder.SaveFile("docx", os.path.join(os.getcwd(), "result.docx"))
builder.CloseFile()
The api object is the ONLYOFFICE Office API (Api) — the same API used by
the editors' macros and plugins, so any macro sample translates directly.
Open and convert an existing document
import docbuilder
builder = docbuilder.CDocBuilder()
builder.OpenFile("contract.docx")
builder.SaveFile("pdf", "contract.pdf")
builder.CloseFile()
Formats are passed as a short string ("docx", "xlsx", "pptx", "pdf", …);
see supported formats.
Format types that have no short name are available as docbuilder.FileTypes
constants — for example a fillable PDF form is saved with
docbuilder.FileTypes.Document.OFORM_PDF.
Run a script and read the result back
For bulk edits it is usually faster to execute one JavaScript command inside the
engine than to cross the Python/native boundary per call. ExecuteCommand can
return a value:
import json
import docbuilder
builder = docbuilder.CDocBuilder()
builder.OpenFile("report.docx")
context = builder.GetContext()
result = context.CreateUndefined()
builder.ExecuteCommand("""
(function() {
var doc = Api.GetDocument();
var texts = [];
var paragraphs = doc.GetAllParagraphs();
for (var i = 0; i < paragraphs.length; ++i)
texts.push(paragraphs[i].GetText());
return JSON.stringify(texts);
})();
""", result)
print(json.loads(result.ToString()))
builder.CloseFile()
Temporary files
The engine writes intermediate data to a temporary directory. Point it at a location of your choice (useful in containers or read-only environments):
builder = docbuilder.CDocBuilder()
builder.SetTmpFolder("/var/tmp/docbuilder")
Main API
| Member | Purpose |
|---|---|
CDocBuilder() |
Builder instance; one open document at a time |
CreateFile(type) |
Create a new empty document of the given type |
OpenFile(path[, params]) |
Open an existing file |
SaveFile(type, path[, params]) |
Save/convert the current document |
CloseFile() |
Close the current document and release resources |
ExecuteCommand(command[, retValue]) |
Run JavaScript against the Office API |
GetContext() |
CDocBuilderContext — JS values, arrays, the global object |
SetTmpFolder(path) |
Override the temporary directory |
Full reference: CDocBuilder, CDocBuilderContext, CDocBuilderValue.
Documentation and samples
- Documentation — https://api.onlyoffice.com/docs/document-builder/get-started/overview/
- Python samples guide — https://api.onlyoffice.com/docs/document-builder/samples/python-samples-guide/
- Sample projects — https://github.com/ONLYOFFICE/document-builder-samples
- Source code — https://github.com/ONLYOFFICE/DocumentBuilder
- Supported formats — https://api.onlyoffice.com/docs/document-builder/get-started/supported-formats/
- Product page — https://www.onlyoffice.com/document-builder.aspx
License
The package is distributed under the GNU AGPL v3.0. The Document Builder engine bundled in the wheel is built from https://github.com/ONLYOFFICE/DocumentBuilder.
If the AGPL does not fit your distribution model, a commercial license is available — see https://www.onlyoffice.com/document-builder.aspx or contact sales@onlyoffice.com.
Support and bug reports: support@onlyoffice.com.
Metadata
Release files for document-builder 10.0.0.170
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 499.8 MB
Release files / document_builder-10.0.0.170-py2.py3-none-win_amd64.whl
| Download URL | document_builder-10.0.0.170-py2.py3-none-win_amd64.whl |
|---|---|
| Size | 86.9 MB |
| Tags | Python 2 Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
dc5e14581bf4f25f36b56e93f2e655934688755dddbe8679a327cd8d72b91cfe
|
|
BLAKE2b-256 checksum How to use checksums |
020ff227dd72607a4d214ca4a03a8c741066e62e7f6d1a2e5a9424f66327ebaf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / document_builder-10.0.0.170-py2.py3-none-win32.whl
| Download URL | document_builder-10.0.0.170-py2.py3-none-win32.whl |
|---|---|
| Size | 82.6 MB |
| Tags | Python 2 Python 3 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
d67debdffde3b706d0148b55c1e95549b5e908961fadbb289c7b2bf62c1da42b
|
|
BLAKE2b-256 checksum How to use checksums |
c536f1854007d4cc4f87f6d9070a658890eadfeeb48d6026edb940c91f8e697a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / document_builder-10.0.0.170-py2.py3-none-manylinux_2_23_x86_64.whl
| Download URL | document_builder-10.0.0.170-py2.py3-none-manylinux_2_23_x86_64.whl |
|---|---|
| Size | 102.2 MB |
| Tags | Linux glibc 2.23+ x86-64 Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
94c3f648277b88dee146ab4a990814c0845ba4b5ea38f414c72619ca1f381006
|
|
BLAKE2b-256 checksum How to use checksums |
b38c6c23b1ec6890d38844b1808f511c36f49d834c85d76cd431c1d957131cf7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / document_builder-10.0.0.170-py2.py3-none-manylinux_2_23_aarch64.whl
| Download URL | document_builder-10.0.0.170-py2.py3-none-manylinux_2_23_aarch64.whl |
|---|---|
| Size | 98.8 MB |
| Tags | Linux glibc 2.23+ ARM64 Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
bc9ce5e95d5f132f37aace437f91542ee5f6ce4d7a224ac3ea4a2451cdd6c303
|
|
BLAKE2b-256 checksum How to use checksums |
3bb3484b17dfa63839c1d088da7e28af5102e95b8e72aeeb6831a1814ed9a9e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / document_builder-10.0.0.170-py2.py3-none-macosx_11_0_arm64.whl
| Download URL | document_builder-10.0.0.170-py2.py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 62.8 MB |
| Tags | Python 2 Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
8ffdba11fa596e79a0715a90d2b11ceb76d82548f5edef34d3e70f2a803b1007
|
|
BLAKE2b-256 checksum How to use checksums |
080d522647a2de095dc1651ece7cdc2acc4c71877bb9bda9425e5a406ef68472
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / document_builder-10.0.0.170-py2.py3-none-macosx_10_9_x86_64.whl
| Download URL | document_builder-10.0.0.170-py2.py3-none-macosx_10_9_x86_64.whl |
|---|---|
| Size | 66.5 MB |
| Tags | Python 2 Python 3 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
9a32a137468c06b07d60362e541d7bf9cbf7fc40de9682179075fda1f4965eb5
|
|
BLAKE2b-256 checksum How to use checksums |
b752d416ea832e6234a0b1f497944c911ab4c15fbfcd4d0bf7e394718c048775
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for document-builder 10.0.0.170
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.