Web Analytics

hwpers

⭐ 179 stars Spanish by Indosaram

hwpers

Crates.io Documentation CI License

Una biblioteca Rust para analizar archivos coreanos Hangul Word Processor (HWP) con soporte completo para renderizado de diseño.

Características

Analizador (Lectura de archivos HWP)

Escritor (Creación de archivos HWP) - v0.3.0+

Inicio rápido

Agrega esto a tu Cargo.toml:

[dependencies]
hwpers = "0.3"

Uso Básico

use hwpers::HwpReader;

// Parse an HWP file let document = HwpReader::from_file("document.hwp")?;

// Extract text content let text = document.extract_text(); println!("{}", text);

// Access document properties if let Some(props) = document.get_properties() { println!("Pages: {}", props.total_page_count); }

// Iterate through sections and paragraphs for (i, section) in document.sections().enumerate() { println!("Section {}: {} paragraphs", i, section.paragraphs.len()); for paragraph in §ion.paragraphs { if let Some(text) = ¶graph.text { println!(" {}", text.content); } } }

Renderizado del Diseño Visual

use hwpers::{HwpReader, render::{HwpRenderer, RenderOptions}};

let document = HwpReader::from_file("document.hwp")?;

// Create renderer with custom options let options = RenderOptions { dpi: 96, scale: 1.0, show_margins: false, show_baselines: false, };

let renderer = HwpRenderer::new(&document, options); let result = renderer.render();

// Export first page to SVG if let Some(svg) = result.to_svg(0) { std::fs::write("page1.svg", svg)?; }

println!("Rendered {} pages", result.pages.len());

Creación de Documentos (v0.3.0+)

use hwpers::writer::HwpWriter;
use hwpers::model::hyperlink::Hyperlink;

// Create a new document let mut writer = HwpWriter::new();

// Add formatted text writer.add_aligned_paragraph( "제목", hwpers::writer::style::ParagraphAlignment::Center )?;

// Add hyperlinks let link = Hyperlink::new_url("Rust", "https://rust-lang.org"); writer.add_paragraph_with_hyperlinks( "Visit Rust website", vec![link] )?;

// Configure page layout writer.set_custom_page_size(210.0, 297.0, // A4 size hwpers::model::page_layout::PageOrientation::Portrait)?; writer.set_page_margins_mm(20.0, 20.0, 20.0, 20.0);

// Add header and footer writer.add_header("Document Header"); writer.add_footer_with_page_number("Page ", hwpers::model::header_footer::PageNumberFormat::Numeric);

// Save the document writer.save_to_file("output.hwp")?;

Acceso a Formateo Avanzado

// Access character and paragraph formatting
for section in document.sections() {
    for paragraph in §ion.paragraphs {
        // Get paragraph formatting
        if let Some(para_shape) = document.get_para_shape(paragraph.para_shape_id as usize) {
            println!("Indent: {}, Alignment: {}", 
                para_shape.indent, 
                para_shape.get_alignment()
            );
        }
        
        // Get character formatting runs
        if let Some(char_shapes) = ¶graph.char_shapes {
            for pos_shape in &char_shapes.char_positions {
                if let Some(char_shape) = document.get_char_shape(pos_shape.char_shape_id as usize) {
                    println!("Position {}: Size {}, Bold: {}", 
                        pos_shape.position,
                        char_shape.base_size / 100,
                        char_shape.is_bold()
                    );
                }
            }
        }
    }
}

Funciones Soportadas

Estructura del Documento

Tipos de Contenido

Diseño y Renderizado

Funciones Avanzadas

Herramienta de Línea de Comandos

La biblioteca incluye una herramienta de línea de comandos para inspeccionar archivos HWP:

# Install the tool
cargo install hwpers

Inspect an HWP file

hwp_info document.hwp

Soporte de Formato

Esta biblioteca soporta archivos en formato HWP 5.0. Para formatos HWP más antiguos, considere usar herramientas de conversión de formato primero.

Funciones del Escritor (v0.3.0+)

La funcionalidad del escritor HWP ha sido mejorada significativamente con soporte integral de características:

✅ Completamente Implementado

❌ Aún no implementado

🔧 Problemas conocidos

Contribuir

¡Las contribuciones son bienvenidas! No dude en enviar una Pull Request. Para cambios importantes, por favor abra un issue primero para discutir lo que desea cambiar.

Licencia

Este proyecto está licenciado bajo cualquiera de

a su elección.

Agradecimientos

--- Tranlated By Open Ai Tx | Last indexed: 2026-03-13 ---