Repository navigation
Python Integration ko
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"
|
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