Repository navigation
Python Integration de
kudryavskiy_rv edited this page Jul 5, 2026
·
1 revision
Abhängigkeitsfreier Wrapper für das office-print CLI.
office_print.py ins Projekt kopieren — kein pip, keine Abhängigkeiten.
from office_print import convert, convert_bytes
# Datei
result = convert("bericht.docx", "bericht.pdf")
assert result.returncode == 0
# Bytes
with open("vorlage.docx", "rb") as f:
data = f.read()
result = convert_bytes(data, ".docx", "ausgabe.pdf")
# Mit Optionen
result = convert(
"bericht.docx", "bericht.pdf",
format="jpeg", jpeg_quality=85,
paper="a4", landscape=True,
font_paths=["./schriften"],
)Gibt subprocess.CompletedProcess zurück.
| Argument | Typ | Standard | Beschreibung |
|---|---|---|---|
input_file |
str | Path |
— |
.docx, .xlsx, .pptx
|
output_file |
str | Path |
None |
Ausgabepfad |
output_dir |
str | Path |
None |
Ausgabeverzeichnis für Stapel |
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 |
Zusätzl. Schriftverzeichnisse |
sheets |
str |
None |
XLSX: "Sheet1,Data"
|
slides |
str |
None |
PPTX: "1-5"
|
streaming |
bool |
False |
Große XLSX |
pdf_a |
bool |
False |
PDF/A-2b |
tagged |
bool |
False |
Strukturiertes PDF |
pdf_ua |
bool |
False |
PDF/UA-1 |
Wie convert() aber für Bytes. Nutzt temporäre Datei.
Mehrere PDFs zu einem zusammenführen.
PDF nach Seitenbereichen aufteilen. ranges = ["1-3", "5"].
-
office-printim PATH oder nebenoffice_print.py
📖 English Docs