OFD to Image/PDF transformation library
Project description
ofd2img
一个轻量级的 OFD/PDF 文档转图片 Python 库
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 许可证。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ofd2img-0.1.0.tar.gz
(61.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ofd2img-0.1.0-py3-none-any.whl
(69.2 kB
view details)
File details
Details for the file ofd2img-0.1.0.tar.gz.
File metadata
- Download URL: ofd2img-0.1.0.tar.gz
- Upload date:
- Size: 61.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e7082b3e1fe71e7313953922c0a0f7e6ce442a1afb0c9ff632c3b42235afc79
|
|
| MD5 |
7590d8ea4f9392543fd3a0264b22ff2f
|
|
| BLAKE2b-256 |
8497df56ad2e93a0b3fe949ff440efa36bbd26ed0475524072697c447e19032e
|
File details
Details for the file ofd2img-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ofd2img-0.1.0-py3-none-any.whl
- Upload date:
- Size: 69.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e8888fa5c1d251cbc6eb9c7c90578cf5b8a1691bd6b1a065a2c1bd8b8482121
|
|
| MD5 |
3f39bc4423a3dee6c3fe3a6f73a1383f
|
|
| BLAKE2b-256 |
5389128e8298149c53f7dc3103c98e0b5c95a3c1fc8a5657a7e026b548a1acf2
|