| Crates.io | docx-lite |
| lib.rs | docx-lite |
| version | 0.2.0 |
| created_at | 2025-09-27 06:31:28.256618+00 |
| updated_at | 2025-09-27 07:03:56.889389+00 |
| description | Lightweight, fast DOCX text extraction library with minimal dependencies |
| homepage | https://github.com/v-lawyer/docx-lite |
| repository | https://github.com/v-lawyer/docx-lite |
| max_upload_size | |
| id | 1857042 |
| size | 46,808 |
A lightweight, fast DOCX text extraction library for Rust with minimal dependencies.
zip, quick-xml, and thiserror)Add this to your Cargo.toml:
[dependencies]
docx-lite = "0.2.0"
use docx_lite::extract_text;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let text = extract_text("document.docx")?;
println!("{}", text);
Ok(())
}
use docx_lite::{parse_document_from_path, ExtractOptions};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let doc = parse_document_from_path("document.docx")?;
// Extract text with all options enabled
let options = ExtractOptions::all();
let text = doc.extract_text_with_options(&options);
println!("{}", text);
// Or customize extraction
let custom_options = ExtractOptions {
include_headers: true,
include_footers: true,
include_footnotes: false,
include_endnotes: false,
include_list_markers: true,
};
let custom_text = doc.extract_text_with_options(&custom_options);
// Access specific elements
for list_item in &doc.lists {
println!("List item (level {}): {}", list_item.level, list_item.text);
}
for footnote in &doc.footnotes {
println!("Footnote {}: {}",
footnote.id,
footnote.paragraphs[0].to_text()
);
}
Ok(())
}
extract_text(path) - Extract all text from a DOCX fileextract_text_from_bytes(bytes) - Extract text from DOCX bytesextract_text_from_reader(reader) - Extract text from any readerparse_document(reader) - Parse DOCX into a structured Documentparse_document_from_path(path) - Parse DOCX file into a structured Documentdocx-lite is designed for speed and efficiency:
Unlike other DOCX libraries in the Rust ecosystem, docx-lite:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is dual-licensed under MIT OR Apache-2.0.
Developed by the V-Lawyer team as part of our commitment to open source.