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