Skip to main content

OFD → PDF 转换工具

基于 ofd-utility 的 ofd-cli,用 Python 封装:OFD 渲染为页面图片 → 合成为 PDF。

官方构建支持 Windows / Linux,可通过 PyPI 平台 wheel 安装,或下载 独立可执行文件。

原理

  1. 调用 ofd-cli render 将各页光栅化为 PNG(或其它格式)
  2. 用 Pillow 按页序合并为多页 PDF

安装(PyPI)

pip install ofd2pdf
# 或
uv add ofd2pdf

安装的是当前平台的 wheel,内置对应系统的 ofd-cli 二进制,无需本机安装 Rust。

纯源码 sdist 不包含 ofd-cli。若仅装到 sdist,请自行构建二进制或设置 OFD_CLI。

独立二进制(无 Python 环境)

GitHub Release 产物中的 ofd2pdf-<os>-<arch>(PyInstaller onefile)可直接运行:

./ofd2pdf-linux-x86_64 input.ofd -o out.pdf
ofd2pdf-windows-amd64.exe input.ofd -o out.pdf

本地开发

uv sync --group dev
bash scripts/build_ofd_cli.sh    # 或 build_ofd_cli.ps1
uv run ofd2pdf sample.ofd -o out.pdf --dpi 200

也可手动指定:

export OFD_CLI=/path/to/ofd-cli      # Unix
set OFD_CLI=C:\path\to\ofd-cli.exe # Windows

用法

ofd2pdf sample.ofd
ofd2pdf sample.ofd -o out.pdf --dpi 200
ofd2pdf sample.ofd --keep-images --images-dir ./pages
ofd2pdf sample.ofd --info

库调用:

from ofd2pdf import convert_ofd_to_pdf

pdf = convert_ofd_to_pdf("sample.ofd", "out.pdf", dpi=150)

发布(仅 GitHub Actions)

打包与上传 只在 CI 完成:打 v* tag 后,Actions 会构建多平台 wheel / sdist / 独立二进制,挂到 GitHub Release,并自动上传 PyPI。

git tag v0.2.1
git push origin v0.2.1
# 进度: https://github.com/rhq-git/ofd2pdf/actions

也可在 Actions → Release → Run workflow,填已有 tag 补打并重新上传(PyPI 已有文件会 skip-existing)。

前置:在 PyPI 为该项目配置 Trusted Publishing(OIDC),Workflow 填 release.yml。

产物示例(Windows / Linux):

  • ofd2pdf-*-py3-none-win_amd64.whl
  • ofd2pdf-*-py3-none-manylinux*.whl(经 auditwheel 修复;PyPI 不接受裸 linux_*)
  • ofd2pdf-windows-amd64.exe / ofd2pdf-linux-x86_64

目录结构

ofd2pdf/
├── src/ofd2pdf/           # Python 包
│   └── bin/               # 构建时放入的 ofd-cli(随平台 wheel 发布)
├── scripts/               # ofd-cli / standalone 构建脚本(供 CI / 本地开发)
├── hatch_build.py         # 平台 wheel 标记
└── .github/workflows/     # CI 与 Release

许可证

本项目为 MIT(见 LICENSE)。

捆绑 / 依赖的 ofd-utility(ofd-cli)同为 MIT;上游版权与许可全文见 NOTICE。

Metadata

Release files for ofd2pdf 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ofd2pdf 0.3.2
File Size Uploaded Provenance Actions
ofd2pdf-0.3.2.tar.gz 10.0 kB With provenance Details for ofd2pdf-0.3.2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for ofd2pdf 0.3.2
File Interpreter ABI Platform Actions
ofd2pdf-0.3.2-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for ofd2pdf-0.3.2-py3-none-win_amd64.whl
ofd2pdf-0.3.2-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for ofd2pdf-0.3.2-py3-none-manylinux_2_28_x86_64.whl

Total release size: 5.0 MB

Release files / ofd2pdf-0.3.2.tar.gz

Download URL ofd2pdf-0.3.2.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
dc218dd4215b20c4f38a648f95527e4a33766c2df9621a83f8f39f4b5f9f09a7
BLAKE2b-256 checksum
How to use checksums
a8b344ddd8020095c4a89ab65691bf02f86678fa01264c7482fbb059e87289b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / ofd2pdf-0.3.2-py3-none-win_amd64.whl

Download URL ofd2pdf-0.3.2-py3-none-win_amd64.whl
Size 2.2 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
8576d4c4cfb68fc1da23767d0d82a547454238809ebad3d661461afc7f29d40a
BLAKE2b-256 checksum
How to use checksums
dd33d7ff838f6617ea301c0d0e250dcff56373aa07a53776eaa4a3b6a9a9e0d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / ofd2pdf-0.3.2-py3-none-manylinux_2_28_x86_64.whl

Download URL ofd2pdf-0.3.2-py3-none-manylinux_2_28_x86_64.whl
Size 2.8 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
3e4304c5eaafcda74d4c8994dd3d9e17cbf235fd29de204b90f42a3c47a2a91f
BLAKE2b-256 checksum
How to use checksums
b767587bb3444d8e1c86b0f8d16db42037a0768d64e32ca086a73e29ed02aad2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for ofd2pdf 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 3 files in this release have been uploaded with provenance metadata.

Select from 3 files

Attestation for ofd2pdf-0.3.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.2 This release

3 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page