Skip to main content

Python bindings for native rhwp HWP to PDF conversion

Project description

hwp-ingest

CI PyPI Python versions License

Rust-backed Python package for Korean HWP/HWPX ingestion.
Current public alpha: HWP to PDF conversion through a small typed Python facade.

Current alpha scope

0.1.0a1 is a public alpha for HWP to PDF conversion. Install it with an exact pre-release pin:

uv pip install hwp-ingest==0.1.0a1
# or
python -m pip install hwp-ingest==0.1.0a1

Release CI is configured to build Linux x86_64/aarch64, macOS Intel/Apple Silicon, and Windows x86_64 wheels. Native runner wheel jobs install rsvg-convert and run a PDF conversion smoke test; the Linux aarch64 job cross-builds the wheel and verifies the artifact payload before publishing.

Runtime PDF dependency

PDF conversion requires the rsvg-convert executable from librsvg at runtime. The Python wheel does not bundle this executable.

Check availability:

rsvg-convert --version

Install examples:

# Debian/Ubuntu
sudo apt-get install librsvg2-bin

# Fedora/RHEL
sudo dnf install librsvg2-tools

# Arch Linux
sudo pacman -S librsvg

# macOS
brew install librsvg

On Windows, install librsvg/rsvg-convert and ensure rsvg-convert.exe is on PATH. If rsvg-convert is missing, PDF conversion raises hwp_ingest.HwpIngestError with a clear message. svg2pdf is not used as an automatic fallback because it is known to drop clipped table text in some HWP documents.

Quick start

Convert an HWP file to a PDF next to the input file:

from pathlib import Path

import hwp_ingest

input_path = Path("document.hwp")
output_path = hwp_ingest.to_pdf_file(input_path, overwrite=True)
print(output_path)

Convert one zero-based page to bytes:

from pathlib import Path

import hwp_ingest

pdf_bytes = hwp_ingest.to_pdf_bytes(
    Path("document.hwp").read_bytes(),
    page_index=0,
)
Path("page-1.pdf").write_bytes(pdf_bytes)

Read basic document metadata:

from pathlib import Path

import hwp_ingest

info = hwp_ingest.analyze_bytes(Path("document.hwp").read_bytes())
print(info.page_count)

Python API

The package is typed and ships py.typed plus checked-in .pyi stubs.

hwp_ingest.analyze_bytes(data: bytes) -> hwp_ingest.DocumentInfo

Returns a DocumentInfo object. DocumentInfo.page_count is the number of renderable pages discovered in the HWP bytes.

hwp_ingest.to_pdf_bytes(
    data: bytes,
    *,
    page_index: int | None = None,
) -> bytes

Returns PDF bytes. page_index is zero-based. Pass None to convert the full document.

hwp_ingest.to_pdf_file(
    input_path: str | os.PathLike[str],
    output_path: str | os.PathLike[str] | None = None,
    *,
    page_index: int | None = None,
    overwrite: bool = False,
) -> pathlib.Path

Writes a PDF and returns the output path. If output_path is None, the output uses the input path with a .pdf suffix. Existing output files are protected unless overwrite=True.

Errors

  • ValueError: negative page_index, empty documents, or out-of-range pages.
  • FileExistsError: output exists and overwrite=False.
  • FileNotFoundError: input file path does not exist.
  • hwp_ingest.HwpIngestError: parse, render, PDF backend, or output write failures.

Local development

cargo test --workspace
uv run maturin develop
uv run pytest

Build distributable artifacts locally:

uv run maturin sdist --out dist
uv run --with ziglang maturin build --release --locked --out dist --compatibility pypi --zig

Notices

This project includes vendored portions of rhwp.

본 제품은 한글과컴퓨터의 HWP 문서 파일(.hwp) 공개 문서를 참고하여 개발하였습니다.

"한글", "한컴", "HWP", and "HWPX" are registered trademarks of Hancom Inc. hwp-ingest is an independent open-source project and is not affiliated with, sponsored by, or endorsed by Hancom Inc.

See NOTICE, THIRD_PARTY_LICENSES.md, and vendor/rhwp-subset/NOTICE for vendored source attribution and license details.

Project direction

See docs/rhwp-python-binding-plan.md for batch engine, semantic output, vendor/upstream sync, and production pipeline direction.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hwp_ingest-0.1.0a1.tar.gz (2.5 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

hwp_ingest-0.1.0a1-cp310-abi3-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.10+Windows x86-64

hwp_ingest-0.1.0a1-cp310-abi3-manylinux_2_28_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

hwp_ingest-0.1.0a1-cp310-abi3-manylinux_2_28_aarch64.whl (2.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

hwp_ingest-0.1.0a1-cp310-abi3-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

hwp_ingest-0.1.0a1-cp310-abi3-macosx_10_12_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file hwp_ingest-0.1.0a1.tar.gz.

File metadata

  • Download URL: hwp_ingest-0.1.0a1.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hwp_ingest-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 a10cebe19dff1b947473902f28a91325c246e978ac976641afb69eabe91fb61f
MD5 2f8a72a8151772d422168d549f53f4b0
BLAKE2b-256 56020a4a2f0e4b27e2d8cb1b964804e010f96077cfa5f3e85799760bdebb2943

See more details on using hashes here.

Provenance

The following attestation bundles were made for hwp_ingest-0.1.0a1.tar.gz:

Publisher: publish.yml on iosif2/hwp-ingest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hwp_ingest-0.1.0a1-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for hwp_ingest-0.1.0a1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 cb66fc15482642691d7d6a34852346bcfea3da65ca9f85484c32c8479e99e250
MD5 74a11e937228ffb34b6bc0e7fdde55b2
BLAKE2b-256 d62eab09f34c64ea30745988188269e2570b32ffcb69a1fe0355ee80286ce270

See more details on using hashes here.

Provenance

The following attestation bundles were made for hwp_ingest-0.1.0a1-cp310-abi3-win_amd64.whl:

Publisher: publish.yml on iosif2/hwp-ingest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hwp_ingest-0.1.0a1-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hwp_ingest-0.1.0a1-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 10b11d3ca35d48cee44476d75aecfa3aebcc3731ddfb80ce6dd0f79eac8b38fc
MD5 28ca91b533a54a8cd554305201bd4383
BLAKE2b-256 d95c830f348db39f5f514f28e4e2489b202a02a21ebfb19fc5db90037178ea2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for hwp_ingest-0.1.0a1-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: publish.yml on iosif2/hwp-ingest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hwp_ingest-0.1.0a1-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for hwp_ingest-0.1.0a1-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3ef0ac7a94f97542454fff74b09395b5cb5a60230f891f7692c2883c985b6562
MD5 01729fda830ca73b6ca98d6883639e39
BLAKE2b-256 e95971023883f4e099bf031afb040cad5eeaa208e7b0eacea2d472550ebb287d

See more details on using hashes here.

Provenance

The following attestation bundles were made for hwp_ingest-0.1.0a1-cp310-abi3-manylinux_2_28_aarch64.whl:

Publisher: publish.yml on iosif2/hwp-ingest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hwp_ingest-0.1.0a1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hwp_ingest-0.1.0a1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0dae1e3fed79130e5621bfa2ec848a9fdd074c94a52c605365dece1ae91fd2a9
MD5 94c6d627ecd947fdf884676446756a52
BLAKE2b-256 7a2719d1cf927865bae5b0294d286b760308dfe83fe222a1392af24822b212ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for hwp_ingest-0.1.0a1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on iosif2/hwp-ingest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hwp_ingest-0.1.0a1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for hwp_ingest-0.1.0a1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b5f0ffaf799f35ee61999dc80e2c03c857cb100512bac761a675c90f38f6bf65
MD5 c41246cff70ab500f102732682308319
BLAKE2b-256 dce46c71470de88d3de0741f8a72454624866e9fba10577e0e7f670d69246898

See more details on using hashes here.

Provenance

The following attestation bundles were made for hwp_ingest-0.1.0a1-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: publish.yml on iosif2/hwp-ingest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page