Expand description
HWPX format codec for HwpForge.
This crate reads and writes HWPX files (ZIP archives containing XML, per KS X 6101), converting between HwpForge Core’s document types and the HWPX on-disk format.
§Architecture
Decoding (HWPX → Core):
- Open ZIP, validate mimetype, enumerate section files
- Parse
Contents/header.xml→HwpxStyleStore - Parse
Contents/section*.xml→ paragraphs + page settings - Assemble
Document<Draft>with sections
Encoding (Core → HWPX):
- Serialize
HwpxStyleStore→header.xml - Serialize each section →
section{N}.xml - Package into ZIP with metadata files
§Quick Start
use hwpforge_smithy_hwpx::{HwpxDecoder, HwpxEncoder};
// Decode
let result = HwpxDecoder::decode_file("document.hwpx").unwrap();
println!("Sections: {}", result.document.sections().len());
// Round-trip: decode → validate → encode
let validated = result.document.validate().unwrap();
let output = HwpxEncoder::encode(&validated, &result.style_store, &result.image_store).unwrap();
std::fs::write("output.hwpx", &output).unwrap();§Supported Content
- Text runs with character shapes, paragraph shapes, styles
- Tables (nested), images (binary + path), text boxes
- Headers, footers, page numbers, footnotes, endnotes
- Shapes: line, ellipse, polygon, arc, curve, connect line
- Equations (HancomEQN), charts (18 types, OOXML)
- Multi-column layouts, captions, bookmarks, fields, memos
- Page settings (size, margins, landscape, gutter, master pages)
Not yet supported:
- OLE objects, form controls, change tracking
Re-exports§
pub use decoder::HwpxDecoder;pub use decoder::HwpxDocument;pub use default_styles::DefaultStyleEntry;pub use default_styles::HancomStyleSet;pub use error::HwpxError;pub use error::HwpxErrorCode;pub use error::HwpxResult;pub use style_store::HwpxCharShape;pub use style_store::HwpxFont;pub use style_store::HwpxFontRef;pub use style_store::HwpxParaShape;pub use style_store::HwpxStyle;pub use style_store::HwpxStyleStore;
Modules§
- decoder
- HWPX decoding pipeline.
- default_
styles - Version-aware default style definitions for 한글 (Hangul Word Processor).
- error
- Error types for the HWPX decoder.
- style_
store - HWPX-specific style storage.
Structs§
- Hwpx
Encoder - Encodes Core documents to HWPX format (ZIP + XML).