Repository navigation
Python Integration ru
kudryavskiy_rv edited this page Jul 5, 2026
·
1 revision
Обёртка без зависимостей для office-print CLI.
Скопируйте office_print.py в проект — pip не нужен, зависимостей нет.
from office_print import convert, convert_bytes
# Файл
result = convert("report.docx", "report.pdf")
assert result.returncode == 0
# Байты
with open("template.docx", "rb") as f:
data = f.read()
result = convert_bytes(data, ".docx", "output.pdf")
# С опциями
result = convert(
"report.docx", "report.pdf",
format="jpeg", jpeg_quality=85,
paper="a4", landscape=True,
font_paths=["./fonts"],
)Возвращает subprocess.CompletedProcess.
| Аргумент | Тип | По умол. | Описание |
|---|---|---|---|
input_file |
str | Path |
— |
.docx, .xlsx, .pptx
|
output_file |
str | Path |
None |
Путь к результату |
output_dir |
str | Path |
None |
Папка для пакетной |
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 |
Доп. папки шрифтов |
sheets |
str |
None |
XLSX: "Sheet1,Data"
|
slides |
str |
None |
PPTX: "1-5"
|
jobs |
int |
0 |
Параллельно (0 = все ядра) |
streaming |
bool |
False |
Большие XLSX |
pdf_a |
bool |
False |
PDF/A-2b |
tagged |
bool |
False |
Тегированный PDF |
pdf_ua |
bool |
False |
PDF/UA-1 |
Как convert(), но для байтов. Использует временный файл.
Склеить несколько PDF в один.
Разрезать PDF по диапазонам. ranges = ["1-3", "5"].
-
office-printв PATH или рядом сoffice_print.py
📖 English Docs