Skip to main content

pdf2ofd

Convert PDF files to OFD (Open Fixed-layout Document) format — a Chinese national standard for electronic documents (GB/T 33190-2016).

Features

  • Full vector path conversion (SVG → OFD), supporting all SVG path commands: M L H V Q C S T A Z
  • Native OFD path commands: M L Q B A C — no lossy approximation
  • Image extraction with RGBA transparency support
  • Multi-page PDF support
  • Command-line interface and Python API

Installation

pip install pdf2ofd

Note: Requires pymupdf>=1.24.0,<1.25.0. Newer versions have SVG export issues that affect conversion accuracy.

Usage

Command Line

# Convert all pages
pdf2ofd input.pdf output.ofd

# Convert specific pages (0-indexed)
pdf2ofd input.pdf output.ofd --pages 0,1,2

# Suppress output
pdf2ofd input.pdf output.ofd --quiet

# Show version
pdf2ofd --version

Python API

from pdf2ofd import convert

# Convert all pages
convert("input.pdf", "output.ofd")

# Convert specific pages
convert("input.pdf", "output.ofd", pages="0,1,2")

# Suppress progress output
convert("input.pdf", "output.ofd", verbose=False)

How It Works

PDF
 ├── PyMuPDF SVG export  →  vector paths (glyphs, lines, curves)
 └── PyMuPDF image API   →  images (with RGBA/transparency)
          ↓
        OFD
  • Vector paths are extracted from PyMuPDF's SVG export and converted to OFD AbbreviatedData format
  • Images are extracted directly from PDF resources via get_image_rects(), preserving original quality and supporting multiple placements of the same image
  • All SVG path commands are mapped to native OFD equivalents — cubic Bézier (C) maps to OFD B, arcs (A) map to OFD A

Requirements

  • Python >= 3.10
  • pymupdf >= 1.24.0, < 1.25.0
  • lxml >= 4.9
  • pillow >= 9.0

License

MIT

Metadata

Release files for pdf2ofd 0.1.0

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

Source distribution (sdist)

Source distribution for pdf2ofd 0.1.0
File Size Uploaded Provenance Actions
pdf2ofd-0.1.0.tar.gz 11.2 kB Without provenance Details for pdf2ofd-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 23.4 kB

Release files / pdf2ofd-0.1.0.tar.gz

Download URL pdf2ofd-0.1.0.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
26cd23414171ec511f0653d74edc2159efd10c4061e4e368eb674585f7f265bf
BLAKE2b-256 checksum
How to use checksums
bbb8a319d726a4841caddba038e120ada79ab858a3dfacd748833371b3f40fa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Release files / pdf2ofd-0.1.0-py3-none-any.whl

Download URL pdf2ofd-0.1.0-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f271d77bfb71ca9bc3e30905ba59ff38019eb576765e25ace0caebba8f3790a
BLAKE2b-256 checksum
How to use checksums
92d318e4bfcf7e527f42e1b9e753176abb9ba30d0453db719bb4b649b3331294
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Security for pdf2ofd 0.1.0

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.

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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No 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