Crate docx_lite

Crate docx_lite 

Source
Expand description

§docx-lite

A lightweight, fast DOCX text extraction library with minimal dependencies.

§Features

  • Zero unsafe code
  • Minimal dependencies (only zip, quick-xml, thiserror)
  • Fast text extraction
  • Support for paragraphs, tables, and basic formatting
  • Graceful error handling for malformed documents

§Quick Start

use docx_lite::extract_text;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let text = extract_text("document.docx")?;
    println!("{}", text);
    Ok(())
}

§Advanced Usage

use docx_lite::parse_document_from_path;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let doc = parse_document_from_path("document.docx")?;

    for paragraph in &doc.paragraphs {
        println!("Paragraph: {}", paragraph.to_text());
    }

    for table in &doc.tables {
        println!("Table with {} rows", table.rows.len());
    }

    Ok(())
}

Re-exports§

pub use error::DocxError;
pub use error::Result;
pub use types::Document;
pub use types::Paragraph;
pub use types::Run;
pub use types::Table;
pub use types::TableRow;
pub use types::TableCell;
pub use types::ListItem;
pub use types::ListType;
pub use types::HeaderFooter;
pub use types::HeaderFooterType;
pub use types::Note;
pub use types::NoteType;
pub use types::ExtractOptions;
pub use extractor::extract_text;
pub use extractor::extract_text_from_bytes;
pub use extractor::extract_text_from_reader;
pub use extractor::parse_document;
pub use extractor::parse_document_from_path;

Modules§

error
extractor
parser
types