Crate hwpforge

Crate hwpforge 

Source
Expand description

§HwpForge

Programmatic control of Korean HWP/HWPX documents.

HwpForge lets you read, write, and convert Hancom 한글 documents from Rust. It targets the HWPX format (ZIP + XML, KS X 6101) used by modern versions of 한글.

§Feature Flags

FeatureDefaultDescription
hwpxHWPX encoder/decoder
mdMarkdown ↔ Core conversion
fullAll features

§Quick Start

use hwpforge::core::{Document, Draft, Paragraph, Run, Section};
use hwpforge::foundation::HwpUnit;

// Build a document programmatically
let mut doc = Document::<Draft>::new();
let section = Section::new(vec![
    Paragraph::new("Hello, 한글!", Default::default()),
]);
doc.add_section(section);

§Encode to HWPX

use hwpforge::hwpx::{HwpxEncoder, HwpxStyleStore};
use hwpforge::core::ImageStore;

let validated = doc.validate().unwrap();
let style_store = HwpxStyleStore::with_default_fonts("함초롬바탕");
let image_store = ImageStore::new();
let bytes = HwpxEncoder::encode(&validated, &style_store, &image_store).unwrap();
std::fs::write("output.hwpx", &bytes).unwrap();

§Decode from HWPX

use hwpforge::hwpx::HwpxDecoder;

let result = HwpxDecoder::decode_file("input.hwpx").unwrap();
println!("Sections: {}", result.document.sections().len());

Re-exports§

pub use hwpforge_foundation as foundation;
pub use hwpforge_core as core;
pub use hwpforge_blueprint as blueprint;
pub use hwpforge_smithy_hwpx as hwpx;
pub use hwpforge_smithy_md as md;