Skip to main content

ofd2img

一个轻量级的 OFD/PDF 文档转图片 Python 库

PyPI License

Forked from easyofd,并在其基础上进行了大量改造。本项目遵循 Apache-2.0 许可证。

🛠️ 构建与开发

本项目推荐使用 uv 进行包管理。

本地安装

uv pip install -e .

构建项目

uv build

发布到 PyPI

uv publish

✨ 功能特性(部分未实现)

  • 多格式支持 — 支持 OFD 文档转换为 PDF 文档、PNG、JPG 图片
  • 灵活分页 — 可指定文档的任意页面范围进行转换(单次最多 20 页)
  • 长图合并 — 将多个文档页面合并输出为一张长图(最多 10 页)
  • 跨平台 — 适用于 macOS、Windows 及 Linux
  • 隐私安全 — 纯本地处理,文件不会上传至任何服务器

📦 安装

pip install ofd2img

🚀 快速开始

from ofd2img import OFD

# 初始化
ofd = OFD("path/to/document.ofd")

# 将文档转为图片(默认转换前 20 页)
ofd.to_image(output_dir="./output")

# 指定页面范围
ofd.to_image(output_dir="./output", pages=[1, 3, 5])

# 指定输出格式
ofd.to_image(output_dir="./output", img_type="jpg")

# 合并多页为一张长图
ofd.to_long_image(output_path="./output/merged.png", pages=[1, 2, 3])

📖 使用说明

基本用法

参数 说明 默认值
output_dir 图片输出目录 "./output"
pages 需要转换的页码列表(从 1 开始) 前 20 页
img_type 输出图片格式,支持 png / jpg "png"

转换 PDF 文档

from ofd2img import OFD

ofd = OFD("path/to/document.pdf")
ofd.to_image(output_dir="./output")

输出长图

from ofd2img import OFD

ofd = OFD("path/to/document.ofd")
ofd.to_long_image(output_path="./output/long_image.png", pages=[1, 2, 3, 4, 5])

📄 许可证

本项目遵循 Apache-2.0 许可证。

Metadata

Release files for ofd2img 0.1.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 ofd2img 0.1.2
File Size Uploaded Provenance
ofd2img-0.1.2.tar.gz 62.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ofd2img 0.1.2
File Interpreter ABI Platform
ofd2img-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 132.0 kB

Release files / ofd2img-0.1.2.tar.gz

Download URL ofd2img-0.1.2.tar.gz
Size 62.0 kB
Tags Source
SHA-256 checksum
How to use checksums
164b43a13336b6d58f7a5dcec6d6c114c682f8de9549f694bc1168adb809fe6e
BLAKE2b-256 checksum
How to use checksums
b04b5e0d40ad277447e1e350b0e49a75ffc1cc8931ff26cb1926349abb6b89f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.3

Release files / ofd2img-0.1.2-py3-none-any.whl

Download URL ofd2img-0.1.2-py3-none-any.whl
Size 70.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
794f47ff00ce17d707eb25db21cfa44988e20188c0f9c0c6ca451ddc6d52bd80
BLAKE2b-256 checksum
How to use checksums
2181e1e1132d7e51225ba9527a00df44e57b8142f9320bb613cbdc1e40565398
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.3

Security for ofd2img 0.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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