Skip to content

Python Integration de

kudryavskiy_rv edited this page Jul 5, 2026 · 1 revision

Python-Integration

Abhängigkeitsfreier Wrapper für das office-print CLI.

Installation

office_print.py ins Projekt kopieren — kein pip, keine Abhängigkeiten.

Schnellstart

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"],
)

API

convert(input_file, output_file=None, **kwargs)

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

convert_bytes(data, suffix, output_file=None, **kwargs)

Wie convert() aber für Bytes. Nutzt temporäre Datei.

merge_pdfs(inputs, output)

Mehrere PDFs zu einem zusammenführen.

split_pdf(input_pdf, output_dir, ranges)

PDF nach Seitenbereichen aufteilen. ranges = ["1-3", "5"].

Voraussetzungen

  • office-print im PATH oder neben office_print.py

Home-de

Clone this wiki locally