Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Rust Library

Install

[dependencies]
s1engine = "1.0.1"

Open a Document

#![allow(unused)]
fn main() {
use s1engine::Engine;

let engine = Engine::new();
let data = std::fs::read("report.docx")?;
let doc = engine.open(&data)?;

println!("Title: {:?}", doc.metadata().title);
println!("Text: {}", doc.to_plain_text());
println!("Words: {}", doc.to_plain_text().split_whitespace().count());
}

Create a Document

#![allow(unused)]
fn main() {
use s1engine::{DocumentBuilder, Format};

let doc = DocumentBuilder::new()
    .title("My Report")
    .heading(1, "Introduction")
    .text("Built with Rudra Code.")
    .build();

std::fs::write("output.docx", doc.export(Format::Docx)?)?;
std::fs::write("output.pdf", doc.export(Format::Pdf)?)?;
}

Convert Between Formats

#![allow(unused)]
fn main() {
let doc = engine.open(&std::fs::read("input.docx")?)?;
std::fs::write("output.odt", doc.export(Format::Odt)?)?;
}

Feature Flags

FeatureDescriptionDefault
docxDOCX read/writeYes
odtODT read/writeYes
txtPlain textYes
mdMarkdown (GFM)Yes
pdfPDF exportNo
crdtCollaborationNo
convertFormat conversionNo