Repository navigation
Python Integration
kudryavskiy_rv edited this page Jul 5, 2026
·
1 revision
Zero-dependency Python wrapper for office-print CLI.
Copy office_print.py into your project — no pip, no deps.
from office_print import convert, convert_bytes
# File conversion
result = convert("report.docx", "report.pdf")
assert result.returncode == 0
# Bytes (in-memory)
with open("template.docx", "rb") as f:
data = f.read()
result = convert_bytes(data, ".docx", "output.pdf")
# With options
result = convert(
"report.docx", "report.pdf",
format="jpeg", jpeg_quality=85,
paper="a4", landscape=True,
font_paths=["./fonts"],
)Returns subprocess.CompletedProcess. Check result.returncode == 0.
| Arg | Type | Default | Description |
|---|---|---|---|
input_file |
str | Path |
— |
.docx, .xlsx, .pptx
|
output_file |
str | Path |
None |
Output path |
output_dir |
str | Path |
None |
Batch output dir |
format |
str |
"pdf" |
"pdf", "png", "jpeg"
|
jpeg_quality |
int |
92 |
1–100 |
paper |
str |
None |
"a4", "letter", "legal"
|
landscape |
bool |
False |
|
font_paths |
list |
None |
Extra font dirs |
sheets |
str |
None |
XLSX: "Sheet1,Data"
|
slides |
str |
None |
PPTX: "1-5"
|
streaming |
bool |
False |
Large XLSX |
pdf_a |
bool |
False |
PDF/A-2b |
tagged |
bool |
False |
Accessible PDF |
pdf_ua |
bool |
False |
PDF/UA-1 |
Like convert() but for bytes. Uses temp file internally.
Merge multiple PDFs into one.
Split PDF by page ranges. ranges = ["1-3", "5"].
-
office-printbinary on PATH or next tooffice_print.py
📖 English Docs