ofdreader
English | 中文
ofdreader is a Python library for data extraction, analysis, conversion & manipulation of OFD (Open Fixed-layout Document; China national standard GB/T 33190—2016) documents.
Install
pip install ofdreader
Development:
pip install -e ".[dev]"
pytest
Quick start
from ofdreader import OfdReader, OfdWriter, ofd_to_pdf, ofd_to_pdf_layout
reader = OfdReader("document.ofd")
print(reader.metadata["Author"])
print(reader.page_count)
text = reader.pages[0].extract_text()
full_text = reader.extract_text() # keeps paragraph breaks, joins line wraps
# flat = reader.extract_text(preserve_layout=False) # single continuous string
writer = OfdWriter()
writer.append(reader)
writer.metadata["Author"] = "Updated Author"
writer.write("copy.ofd")
# Export current extracted paragraphs to a simple PDF
ofd_to_pdf("document.ofd", "document.txt-layout.pdf")
# Export with approximate original fonts/layout from OFD XML
ofd_to_pdf_layout("document.ofd", "document.layout.pdf")
Merge an extra page from another file:
writer = OfdWriter()
writer.append(OfdReader("a.ofd"))
writer.append_pages(OfdReader("b.ofd"), pages=[0])
writer.write("merged.ofd")
Scope (v0.1)
- Open
.ofdpackages (ZIP) from path, bytes, or file-like objects - Read
DocInfometadata, page list, outlines - Extract plain text from
TextObject/TextCode(default keeps paragraph breaks, joins wrapped lines) - Clone packages, update metadata, append pages across documents
- Export extracted text paragraphs to PDF (
ofd_to_pdf, optionalreportlab) - Export approximate original layout PDF (
ofd_to_pdf_layout)
Not included yet: full layout rendering, digital signatures, annotations, creating new glyph-mapped text.
Related projects
- easyofd — OFD ↔ PDF/image conversion
- PyPI name
pyofdis a different library (tax receipt OFD providers)
License
MIT — see LICENSE.
Metadata
Release files for ofdreader 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ofdreader-0.1.0.tar.gz | 12.4 kB | With provenance | Details for ofdreader-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ofdreader-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for ofdreader-0.1.0-py3-none-any.whl |
Total release size: 15.4 kB
Release files / ofdreader-0.1.0.tar.gz
| Download URL | ofdreader-0.1.0.tar.gz |
|---|---|
| Size | 12.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
efeeb7553b6596f05fb8acc915ba92042d2ed0476d718a0bf8b391afc5c066ec
|
|
BLAKE2b-256 checksum How to use checksums |
75d6ffd59a159d1578e94e057d8b6042a77b29612ef79ad76ee2112e3bf6f32a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 1, 2026.
Transparency logRelease files / ofdreader-0.1.0-py3-none-any.whl
| Download URL | ofdreader-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
16eda85b84692916aff29de0ccca67c865ad69fa1a84dd8e221f816ed9dee832
|
|
BLAKE2b-256 checksum How to use checksums |
c5bba422054775a9053ce0a2392b51483f4b7de4955ff91e5266d6e6c4eadda8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 1, 2026.
Transparency logSecurity for ofdreader 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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ofdreader-0.1.0.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 Jun 1, 2026.
Transparency logA 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.