### Rust example using docboss-core, docboss-output, docboss-layout, docboss-render Source: https://github.com/4thel00z/docboss/blob/master/docs/src/quickstart.md Shows a Rust program that opens a document, converts it to Markdown, lays out the document, and renders the first page to a PNG. Requires adding the crates docboss-core, docboss-output, docboss-layout, and docboss-render. ```rust use docboss_output::{to_markdown, MarkdownOptions}; fn main() -> Result<(), Box> { let doc = docboss_core::open("report.docx")?; println!("{}", to_markdown(&doc, &MarkdownOptions::default())); let layout = docboss_layout::layout_document(&doc); docboss_render::render_page(&layout, 0, 2.0)?.save("page.png")?; Ok(()) } ``` -------------------------------- ### Install docboss CLI with cargo Source: https://github.com/4thel00z/docboss/blob/master/docs/src/installation.md Builds the `docboss` binary from crates.io with a stable Rust toolchain. From a checkout, `make install` does the same for the working tree. ```bash cargo install docboss-cli ``` -------------------------------- ### docboss skill install command help Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/cli.md Shows usage for the `docboss skill install` subcommand, which installs the skill for coding agents. By default it installs into `./.claude/skills/docboss` (this project); use `--global` to install into `~/.claude/skills/docboss`. ```text Install the skill for coding agents: into ./.claude/skills/docboss (this project), or with --global into ~/.claude/skills/docboss Usage: docboss skill install [OPTIONS] Options: -g, --global Install into ~/.claude/skills instead of ./.claude/skills -h, --help Print help ``` -------------------------------- ### Reproduce all benchmarks (fetch corpus, build, install deps, run bench scripts) Source: https://github.com/4thel00z/docboss/blob/master/benchmarks/README.md Run from the repository root. Fetches the corpus, builds the Rust extension with maturin, installs Python dependencies, and runs every benchmark script. Set DOCBOSS_BENCH_TOOLS to locally built antiword and catdoc binaries before running. Each script writes its results-*.json next to itself; numbers are machine-dependent, so compare rows within the same machine only. ```bash ./benchmarks/fetch_corpus.sh corpus/ uv run maturin develop --release uv pip install python-docx docx2python mammoth docx2txt pypandoc_binary psutil numpy pillow export DOCBOSS_BENCH_TOOLS=/path/to/antiword:/path/to/catdoc/src # locally built binaries uv run python benchmarks/bench.py docx corpus/ --sample 80 --libreoffice uv run python benchmarks/bench.py doc corpus/ --sample 80 --libreoffice uv run python benchmarks/bench_large.py uv run python benchmarks/bench_parallel.py docx corpus/ --sample 300 uv run python benchmarks/bench_memory.py doc corpus/ --sample 100 uv run python benchmarks/bench_robustness.py mutate docx damaged/docx corpus/ --count 150 uv run python benchmarks/bench_robustness.py run docx damaged/docx uv run python benchmarks/bench_render.py corpus/ uv run python benchmarks/bench_fidelity.py corpus/ --files benchmarks/fidelity-sample.txt --max-pages 5 ``` -------------------------------- ### Install docboss via pip and cargo Source: https://github.com/4thel00z/docboss/blob/master/README.md Install the Python package with pip (abi3 wheels for CPython 3.12+) and the CLI binary with cargo. The CLI binary is named `docboss`. ```bash pip install docboss # abi3 wheels (CPython 3.12+) cargo install docboss-cli # the `docboss` binary ``` -------------------------------- ### Add Rust crates with cargo add Source: https://github.com/4thel00z/docboss/blob/master/docs/src/installation.md Adds the docboss Rust crates. `docboss-core` re-exports the document model, so most programs start from `docboss_core::open`. The `docboss-aio` crate is added with the `http` feature for async and remote reads. ```bash cargo add docboss-core docboss-output docboss-layout docboss-render docboss-write ``` ```bash cargo add docboss-aio --features http # async and remote reads ``` -------------------------------- ### Install docboss Python package with pip Source: https://github.com/4thel00z/docboss/blob/master/docs/src/installation.md Installs the docboss Python package. Wheels are abi3 builds for CPython 3.12 and later, so one wheel covers every later Python version. No Rust toolchain is needed to install one. ```bash pip install docboss ``` -------------------------------- ### CLI commands for docboss Source: https://github.com/4thel00z/docboss/blob/master/docs/src/quickstart.md Shows the main command-line operations: info, text, md, render, images, convert, and create. Page numbers are 1-based on the command line. The render command prints each file it writes; images writes into the given directory and creates it when missing. ```bash docboss info report.docx # format, metadata, page setup, page count, counts docboss text report.docx # plain text with list labels docboss text legacy.doc # Word 97-2003 files read the same way docboss md report.docx # GitHub-flavored Markdown docboss render report.docx --page 1 -o page.png --scale 2 docboss images report.docx -o images # the document's pictures, as stored docboss convert legacy.doc -o legacy.docx # DOC to a fresh DOCX docboss create md notes.md -o notes.docx # Markdown composed into a DOCX ``` -------------------------------- ### docboss CLI usage examples Source: https://github.com/4thel00z/docboss/blob/master/README.md Shows common `docboss` CLI commands for inspecting, converting, and creating documents. Every read command accepts a local path or an `http(s)://` URL, which is read with range requests rather than downloaded whole. ```bash docboss info report.docx # format, metadata, page setup, page count, content counts docboss text report.docx # plain text with list labels; --headers-footers, --comments, --no-notes docboss text legacy.doc # the same for Word 97-2003 files docboss md report.docx # GitHub-flavored Markdown; --images DIR exports and links images docboss html report.docx --standalone # semantic HTML, images embedded as data: URIs docboss json report.docx --blocks # the compact per-block view; omit --blocks for the whole model docboss q report.docx '.metadata.title' -r # jq over the JSON model docboss render report.docx --page 1 -o page.png --scale 2 # or .ppm / .bmp / .jpg; all pages with -o 'page-%d.png' docboss images report.docx -o images # the document's images at their stored size and format docboss convert legacy.doc -o legacy.docx # DOC or DOCX to a fresh DOCX, or .md/.html/.txt/.json by extension docboss create md notes.md -o notes.docx # CommonMark + GFM composed into a DOCX docboss fonts report.docx # each font the document names and the face it resolves to here docboss diagnostics report.docx # everything the lenient reader approximated or dropped docboss parts report.docx # ZIP entries or compound-file streams, with sizes docboss hex legacy.doc WordDocument --length 64 # hexdump a part docboss xml report.docx word/styles.xml # a part, indented docboss text locked.docx --password secret # encrypted DOCX or DOC docboss tui report.docx # interactive terminal explorer ``` -------------------------------- ### Python API usage for docboss Source: https://github.com/4thel00z/docboss/blob/master/docs/src/quickstart.md Demonstrates the Python API: opening a document, extracting text and markdown, rendering a page to PNG, iterating images, converting legacy DOC to DOCX, and creating a DOCX from Markdown. Document also opens from memory with Document(data=raw_bytes), pages are 0-based with negative indexes from the end, and render returns PNG bytes unless format= says otherwise. ```python from pathlib import Path import docboss doc = docboss.Document("report.docx") print(doc.format, doc.page_count(), "pages") text = doc.extract_text() # one line per paragraph, list labels included markdown = doc.extract_markdown() # headings, lists, tables, footnotes, links Path("page.png").write_bytes(doc.render(0, scale=2.0)) for image in doc.images(): print(image.name, image.content_type, len(image.data)) legacy = docboss.Document("legacy.doc") Path("legacy.docx").write_bytes(legacy.to_docx()) docx = docboss.md.to_docx(Path("notes.md").read_text()) ``` -------------------------------- ### Compose a document with DocumentBuilder Source: https://github.com/4thel00z/docboss/blob/master/README.md Builds a Q3 Report document with a title, heading, paragraph with bold text, bullet items, and a table. Uses docboss_write's DocumentBuilder, ListKind, Para, and TableBuilder; the example ends with a hidden Ok to satisfy the doctest. ```rust use docboss_write::{DocumentBuilder, ListKind, Para, TableBuilder}; let mut doc = DocumentBuilder::new(); doc.title("Q3 Report").heading(1, "Summary"); doc.paragraph(Para::new().text("Revenue grew ").bold("12%").text(".")); doc.items(ListKind::Bullet, &["North", "South"]); let width = doc.text_width(); doc.block(TableBuilder::new(2, width).header(&["Region", "Growth"]).row(&["North", "14%"])); let bytes = doc.to_bytes()?; # Ok::<(), docboss_write::Error>(()) ``` -------------------------------- ### docboss q: query the document model Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/explorer.md Runs a jq-style query against the document model. The example extracts style IDs from the styles collection. ```bash docboss q report.docx '.styles.styles | map(.id)' ``` -------------------------------- ### docboss_aio::AsyncDocument::part Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Gets a part of the document. ```APIDOC ## AsyncDocument::part(name) ### Description Gets a part of the document. ### Parameters - **name** (string) - Required - Part name. ### Returns - **Part** - The part. ### Example ```rust let part = async_doc.part("word/document.xml").await?; ``` ``` -------------------------------- ### Rust main function printing hi Source: https://github.com/4thel00z/docboss/blob/master/crates/docboss-write/tests/common/markdown.md A simple Rust program that prints 'hi' to the console. Use this as a minimal example of a main function. ```rust fn main() { println!("hi"); } ``` -------------------------------- ### Python async API with AsyncDocument Source: https://github.com/4thel00z/docboss/blob/master/README.md Shows how to read a document asynchronously from a URL, fetching only the byte ranges each call needs. Use `document()` to get the synchronous Document for rendering and other operations. ```python import asyncio import docboss async def main() -> None: doc = await docboss.AsyncDocument.open_url("https://example.com/report.docx") text = await doc.extract_text() print(doc.format, doc.bytes_fetched, "bytes fetched in", len(doc.requests), "requests") full = await doc.document() # the synchronous Document, for rendering and the rest asyncio.run(main()) ``` -------------------------------- ### Compose DOCX from Rust with DocumentBuilder Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/writing.md Builds a DOCX document programmatically using `DocumentBuilder`, covering metadata, styles, headings, paragraphs, lists, tables, images, footnotes, headers, footers, and sections. The example creates a title, heading, paragraph, bullet list, and table, then serializes to bytes. ```rust use docboss_write::{DocumentBuilder, ListKind, Para, TableBuilder}; let mut doc = DocumentBuilder::new(); doc.title("Q3 Report").heading(1, "Summary"); doc.paragraph(Para::new().text("Revenue grew ").bold("12%").text(".")); doc.items(ListKind::Bullet, &["North", "South"]); let width = doc.text_width(); doc.block(TableBuilder::new(2, width).header(&["Region", "Growth"]).row(&["North", "14%"])); let bytes = doc.to_bytes()?; assert!(bytes.starts_with(b"PK")); # Ok::<(), docboss_write::Error>(()) ``` -------------------------------- ### docboss tui: launch terminal explorer Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/explorer.md Starts the interactive terminal explorer. It requires an interactive terminal and exits with an error otherwise. ```bash docboss tui report.docx ``` -------------------------------- ### docboss json: export document model as JSON Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/explorer.md Outputs the document model as JSON. The example pipes to head to show the beginning of the output. ```bash docboss json report.docx | head ``` -------------------------------- ### AsyncDocument for remote DOCX Source: https://github.com/4thel00z/docboss/blob/master/skills/docboss/SKILL.md Open a DOCX from a URL asynchronously, fetching only the byte ranges needed. Extract text, inspect fetched bytes and requests, and get the full synchronous Document. Errors raise `docboss.DocbossError`. ```python doc = await docboss.AsyncDocument.open_url("https://example.com/report.docx") text = await doc.extract_text() doc.bytes_fetched, doc.requests, doc.part_names() full = await doc.document() # the synchronous Document ``` -------------------------------- ### docboss parts: list ZIP entries and compound-file streams Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/explorer.md Lists ZIP entries with stored and unpacked sizes for .docx files, or compound-file streams for legacy .doc files. Stream names starting with a control character print as \x05SummaryInformation and can be addressed that way, without the prefix, or case-insensitively. ```bash docboss parts report.docx # ZIP entries with stored and unpacked sizes ``` ```bash docboss parts legacy.doc # compound-file streams ``` -------------------------------- ### docboss container explorer commands Source: https://github.com/4thel00z/docboss/blob/master/crates/docboss-cli/skill/SKILL.md Commands for inspecting the internal structure of a document: list ZIP entries or compound streams, view an XML part, or hexdump a part/stream. Use --raw to get XML as stored and --length to limit hexdump output. ```bash docboss parts report.docx # ZIP entries with sizes; for .doc the compound file streams ``` ```bash docboss xml report.docx word/styles.xml # an XML part, re-indented (--raw as stored) ``` ```bash docboss hex report.doc 1Table --length 256 # hexdump a part or stream (or the whole file) ``` -------------------------------- ### Get block view of a document with docboss CLI Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/text.md Use the docboss CLI with --blocks to output JSON block view for retrieval pipelines. Each block keeps its role: kind is paragraph, heading, list_item, or table; headings come from outline levels and heading styles; list items carry their level and label. Empty paragraphs are left out. ```bash docboss json report.docx --blocks ``` -------------------------------- ### Extract text from a document with docboss CLI Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/text.md Use the docboss CLI to extract plain text from a document. Options include --headers-footers, --comments, --no-labels, and -o for output file. Plain text has one line per paragraph; list paragraphs start with the document's numbering label; table rows become one line with tab-separated cells; footnote/endnote references become [1] and [i] and their text follows the main text unless --no-notes is used. Hidden text, deleted revisions, and field instructions are omitted; text boxes are written after the anchoring paragraph. ```bash docboss text report.docx docboss text report.docx --headers-footers --comments docboss text legacy.doc --no-labels -o legacy.txt ``` -------------------------------- ### Open, convert, layout, render, and save a DOCX document Source: https://github.com/4thel00z/docboss/blob/master/README.md Opens a DOCX or DOC file detected from bytes, prints text and Markdown output, lays out the document, renders page 0 at 2.0 scale to page.png, and saves a deterministic copy. Requires the docboss-core, docboss-output, docboss-layout, docboss-render, and docboss-write crates. ```rust use docboss_output::{to_markdown, to_text, MarkdownOptions, TextOptions}; fn main() -> Result<(), Box> { let doc = docboss_core::open("report.docx")?; // DOCX or DOC, detected from the bytes println!("{}", to_text(&doc, &TextOptions::default())); println!("{}", to_markdown(&doc, &MarkdownOptions::default())); let layout = docboss_layout::layout_document(&doc); println!("{} pages", layout.pages.len()); docboss_render::render_page(&layout, 0, 2.0)?.save("page.png")?; docboss_write::save(&doc, "copy.docx")?; // deterministic DOCX Ok(()) } ``` -------------------------------- ### Development Make Targets Source: https://github.com/4thel00z/docboss/blob/master/README.md Lists the primary make targets for CI, Python tests, the Lean conformance gate, and help. Run from the project root. ```bash make ci # rustfmt check, clippy -D warnings, tests, rustdoc make test-py # build the extension and run the Python tests make ledger-gate # the Lean conformance gate make help # everything else ``` -------------------------------- ### docboss_aio::AsyncDocument::open_url_with Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Opens a document from a URL with options. ```APIDOC ## AsyncDocument::open_url_with(url, options) ### Description Opens a document from a URL with options. ### Parameters - **url** (string) - Required - The URL. - **options** (ReadOptions) - Required - Options. ### Returns - **AsyncDocument** - The async document. ### Example ```rust let doc = AsyncDocument::open_url_with(url, options).await?; ``` ``` -------------------------------- ### docboss_aio::AsyncDocument::load_media Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Loads media for the document. ```APIDOC ## AsyncDocument::load_media() ### Description Loads media for the document. ### Returns - **Result** - Result of loading. ### Example ```rust async_doc.load_media().await?; ``` ``` -------------------------------- ### docboss_aio::AsyncDocument::from_backend Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Creates an AsyncDocument from a backend. ```APIDOC ## AsyncDocument::from_backend(backend) ### Description Creates an AsyncDocument from a backend. ### Parameters - **backend** (Backend) - Required - The backend. ### Returns - **AsyncDocument** - The async document. ### Example ```rust let doc = AsyncDocument::from_backend(backend).await?; ``` ``` -------------------------------- ### docboss_aio::AsyncDocument::part_names Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Lists part names. ```APIDOC ## AsyncDocument::part_names() ### Description Lists part names. ### Returns - **Vec** - List of part names. ### Example ```rust let names = async_doc.part_names().await?; ``` ``` -------------------------------- ### docboss_layout::layout_with_options Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Lays out a document with options. ```APIDOC ## layout_with_options(&Document, &Arc, options) ### Description Lays out a document with options. ### Parameters - **document** (Document) - Required - The document to lay out. - **fonts** (Arc) - Required - Font database. - **options** (LayoutOptions) - Required - Layout options. ### Returns - **Layout** - The layout. ### Example ```rust let layout = layout_with_options(&doc, &fonts, options); ``` ``` -------------------------------- ### docboss_core::open Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Opens a document from a file path. Returns a Document with diagnostics. ```APIDOC ## open(path) ### Description Opens a document from a file path. ### Parameters - **path** (string) - Required - Path to the document file. ### Returns - **Document** - The opened document with diagnostics. ### Example ```rust let doc = docboss_core::open("document.docx")?; ``` ``` -------------------------------- ### docboss_aio::AsyncDocument::open Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Opens a document asynchronously from a path. ```APIDOC ## AsyncDocument::open(path) ### Description Opens a document asynchronously from a path. ### Parameters - **path** (string) - Required - Path to the document. ### Returns - **AsyncDocument** - The async document. ### Example ```rust let doc = AsyncDocument::open("document.docx").await?; ``` ``` -------------------------------- ### docboss_aio::AsyncDocument::open_url Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Opens a document from a URL asynchronously. ```APIDOC ## AsyncDocument::open_url(url) ### Description Opens a document from a URL asynchronously. ### Parameters - **url** (string) - Required - The URL. ### Returns - **AsyncDocument** - The async document. ### Example ```rust let doc = AsyncDocument::open_url("https://example.com/doc.docx").await?; ``` ``` -------------------------------- ### docboss_aio::AsyncDocument::from_bytes Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Creates an AsyncDocument from bytes. ```APIDOC ## AsyncDocument::from_bytes(bytes) ### Description Creates an AsyncDocument from bytes. ### Parameters - **bytes** (byte array) - Required - The document bytes. ### Returns - **AsyncDocument** - The async document. ### Example ```rust let doc = AsyncDocument::from_bytes(bytes).await?; ``` ``` -------------------------------- ### docboss_render::render_pages Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Renders all pages of a layout. ```APIDOC ## render_pages(&Layout, scale) ### Description Renders all pages of a layout. ### Parameters - **layout** (Layout) - Required - The layout. - **scale** (f32) - Required - Scale factor. ### Returns - **Vec** - The rendered pages. ### Example ```rust let pages = render_pages(&layout, 1.0); ``` ``` -------------------------------- ### docboss_aio::AsyncDocument::read Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Reads the document with options. ```APIDOC ## AsyncDocument::read(&ReadOptions) ### Description Reads the document with options. ### Parameters - **options** (ReadOptions) - Required - Options. ### Returns - **Document** - The read document. ### Example ```rust let doc = async_doc.read(&ReadOptions::default()).await?; ``` ``` -------------------------------- ### docboss_write::DocumentBuilder Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Builder for creating documents. ```APIDOC ## DocumentBuilder ### Description Builder for creating documents. ### Methods - **new()** - Creates a new builder. - **add_paragraph(Para)** - Adds a paragraph. - **add_table(TableBuilder)** - Adds a table. - **build() -> Document** - Builds the document. ### Example ```rust let doc = DocumentBuilder::new() .add_paragraph(Para::new("Hello")) .build(); ``` ``` -------------------------------- ### Render pages with docboss CLI Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/rendering.md Renders pages from a document to image files. The output format is chosen by the -o extension (.png, .ppm, .bmp, .jpg/.jpeg). Use %d in the path for page numbers; without --page every page is rendered. --scale is pixels per point (1.0 = 72 dpi, 2.0 = 144 dpi). ```bash docboss render report.docx --page 1 -o page.png # one page, 72 dpi docboss render report.docx --scale 2 -o 'page-%d.png' # every page at 144 dpi docboss render report.docx --page 1 -o page.jpg --jpeg-quality 85 docboss render legacy.doc -o 'legacy-%d.ppm' ``` -------------------------------- ### Open remote DOCX with docboss-aio Rust Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/remote.md Uses docboss-aio with the http feature. AsyncDocument::open_url opens a remote document; read() fetches only needed parts. bytes_fetched(), len(), and requests() report fetch statistics. Use ReadOptions { media: true, .. } to fetch images immediately, otherwise AsyncDocument::load_media fetches them later. ```rust use docboss_aio::{AsyncDocument, ReadOptions}; use docboss_output::{to_text, TextOptions}; # async fn run() -> docboss_aio::Result<()> { let remote = AsyncDocument::open_url("https://example.com/report.docx").await?; let doc = remote.read(&ReadOptions::default()).await?; println!("{}", to_text(&doc, &TextOptions::default())); println!("{} of {} bytes in {} requests", remote.bytes_fetched(), remote.len(), remote.requests().len()); # Ok(()) } ``` -------------------------------- ### docboss_layout::layout Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Lays out a document with a font database. ```APIDOC ## layout(&Document, &Arc) ### Description Lays out a document with a font database. ### Parameters - **document** (Document) - Required - The document to lay out. - **fonts** (Arc) - Required - Font database. ### Returns - **Layout** - The layout. ### Example ```rust let layout = layout(&doc, &fonts); ``` ``` -------------------------------- ### docboss_metafile::play Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Plays a WMF or EMF metafile into a Picture. ```APIDOC ## play(bytes) -> Picture ### Description Plays a WMF or EMF metafile into a Picture. ### Parameters - **bytes** (byte array) - Required - The metafile bytes. ### Returns - **Picture** - The picture. ### Example ```rust let picture = docboss_metafile::play(bytes)?; ``` ``` -------------------------------- ### Read a remote DOCX with range requests Source: https://github.com/4thel00z/docboss/blob/master/README.md Opens a remote DOCX via URL using AsyncDocument::open_url and reads it with default ReadOptions, then prints the number of bytes fetched and the total length. Requires the docboss-aio crate with the http feature enabled. ```rust use docboss_aio::{AsyncDocument, ReadOptions}; # async fn run() -> docboss_aio::Result<()> { let remote = AsyncDocument::open_url("https://example.com/report.docx").await?; let doc = remote.read(&ReadOptions::default()).await?; println!("{} of {} bytes fetched", remote.bytes_fetched(), remote.len()); # Ok(()) } ``` -------------------------------- ### docboss_render::render_page Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Renders a page of a layout to a Pixmap. ```APIDOC ## render_page(&Layout, index, scale) -> Pixmap ### Description Renders a page of a layout to a Pixmap. ### Parameters - **layout** (Layout) - Required - The layout. - **index** (usize) - Required - Page index. - **scale** (f32) - Required - Scale factor. ### Returns - **Pixmap** - The rendered image. ### Example ```rust let pixmap = render_page(&layout, 0, 1.0); ``` ``` -------------------------------- ### docboss_core::open_with / read_with Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Opens or reads a document with options, including password for encrypted files. ```APIDOC ## open_with(path, &Options) / read_with(bytes, &Options) ### Description Opens or reads a document with options, including password for encrypted files. ### Parameters - **path** (string) - Required - Path to the document file (for open_with). - **bytes** (byte array) - Required - Document bytes (for read_with). - **options** (Options) - Required - Options including `password` field. ### Returns - **Document** - The opened document. ### Example ```rust let options = docboss_core::Options { password: Some("secret".into()) }; let doc = docboss_core::open_with("locked.docx", &options)?; ``` ``` -------------------------------- ### docboss_output::to_html / write_html Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Converts a document to HTML with HtmlOptions. ```APIDOC ## to_html(&Document, &HtmlOptions) / write_html(&Document, &HtmlOptions, writer) ### Description Converts a document to HTML with HtmlOptions. ### Parameters - **document** (Document) - Required - The document to convert. - **options** (HtmlOptions) - Required - Options for HTML output. - **writer** (Write) - Required for write_html - Output writer. ### Returns - **String** (for to_html) - The HTML representation. - **Result** (for write_html) - Result of writing. ### Example ```rust let html = to_html(&doc, &HtmlOptions { standalone: true, ..HtmlOptions::default() }); ``` ``` -------------------------------- ### docboss_output::to_markdown / write_markdown Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Converts a document to Markdown with MarkdownOptions. ```APIDOC ## to_markdown(&Document, &MarkdownOptions) / write_markdown(&Document, &MarkdownOptions, writer) ### Description Converts a document to Markdown with MarkdownOptions. ### Parameters - **document** (Document) - Required - The document to convert. - **options** (MarkdownOptions) - Required - Options for Markdown output. - **writer** (Write) - Required for write_markdown - Output writer. ### Returns - **String** (for to_markdown) - The Markdown representation. - **Result** (for write_markdown) - Result of writing. ### Example ```rust let md = to_markdown(&doc, &MarkdownOptions::default()); ``` ``` -------------------------------- ### docboss tui command help Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/cli.md Shows usage for the `docboss tui` subcommand, which lets you explore the document interactively in the terminal. Accepts a path or http(s):// URL to a .docx or .doc file, detects format from bytes, and supports an optional password. ```text Explore the document interactively in the terminal Usage: docboss tui [OPTIONS] Arguments: Path or http(s):// URL of the .docx or .doc file; the format is detected from its bytes. A URL is read with range requests Options: --password Password for an encrypted DOC or DOCX -h, --help Print help ``` -------------------------------- ### Convert documents with docboss CLI Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/writing.md Converts DOC, DOCX, or Markdown files to DOCX, Markdown, HTML, TXT, or JSON based on the output extension. Output is deterministic with fixed timestamps. ```bash docboss convert legacy.doc -o legacy.docx # DOC to DOCX docboss convert report.docx -o fresh.docx # a fresh package from the model docboss convert legacy.doc -o legacy.md # or .html, .txt, .json by extension ``` -------------------------------- ### docboss_render::Renderer Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md A renderer for layouts. ```APIDOC ## Renderer ### Description A renderer for layouts. ### Methods - **render_page(&Layout, index, scale) -> Pixmap** - Renders a page. - **render_pages(&Layout, scale) -> Vec** - Renders all pages. ### Example ```rust let renderer = Renderer::new(); let pixmap = renderer.render_page(&layout, 0, 1.0); ``` ``` -------------------------------- ### docboss.md.to_docx Source: https://github.com/4thel00z/docboss/blob/master/crates/docboss-cli/skill/SKILL.md Converts Markdown to DOCX bytes. ```APIDOC ## docboss.md.to_docx ### Description Converts Markdown to DOCX bytes. ### Parameters - `markdown` (str) - Required - Markdown content. - `images_dir` (str) - Optional - Directory for images (default "assets"). ### Returns - DOCX bytes. ``` -------------------------------- ### docboss_write::markdown::to_docx Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Converts Markdown to a DOCX document. ```APIDOC ## markdown::to_docx(markdown) ### Description Converts Markdown to a DOCX document. ### Parameters - **markdown** (string) - Required - The Markdown content. ### Returns - **Document** - The resulting document. ### Example ```rust let doc = markdown::to_docx("# Title")?; ``` ``` -------------------------------- ### docboss_layout::layout_document Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Lays out a document into a Layout. ```APIDOC ## layout_document(&Document) -> Layout ### Description Lays out a document into a Layout. ### Parameters - **document** (Document) - Required - The document to lay out. ### Returns - **Layout** - The layout with pages, fonts, media, diagnostics. ### Example ```rust let layout = layout_document(&doc); ``` ``` -------------------------------- ### Query JSON with docboss json and docboss q Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/markdown.md Exports the document model as JSON. Use --blocks for one object per block, and docboss q to run jq programs (via jaq) over the JSON. ```bash docboss json report.docx # the whole document model docboss json report.docx --blocks # one object per block docboss q report.docx '.sections | length' docboss q report.docx --blocks -r '.[] | select(.kind == "heading") | .text' ``` -------------------------------- ### docboss skill print command help Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/cli.md Shows usage for the `docboss skill print` subcommand, which prints the skill document to stdout. It takes no arguments or options other than `-h, --help`. ```text Print the skill document to stdout Usage: docboss skill print Options: -h, --help Print help ``` -------------------------------- ### Create DOCX from Markdown with docboss CLI Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/writing.md Creates a DOCX from a Markdown file, specifying page size and title. Relative image paths are resolved from the Markdown file's directory. ```bash docboss create md notes.md -o notes.docx --size a4 --title "Notes" ``` -------------------------------- ### docboss_core::detect Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Detects the format of a document from bytes. ```APIDOC ## detect(bytes) -> Format ### Description Detects the format of a document from bytes. ### Parameters - **bytes** (byte array) - Required - The document bytes. ### Returns - **Format** - The detected format. ### Example ```rust let format = docboss_core::detect(bytes); ``` ``` -------------------------------- ### docboss q Source: https://github.com/4thel00z/docboss/blob/master/skills/docboss/SKILL.md Command-line tool to query DOCX files using jq-like expressions. Supports extracting sections, styles, blocks, and diagnostics. ```APIDOC ## docboss q ### Description Command-line tool to query DOCX files using jq-like expressions. Supports extracting sections, styles, blocks, and diagnostics. ### Usage `docboss q [--blocks]` ### Parameters - **file** - Path to the DOCX file. - **jq-expression** - jq expression to apply. - **--blocks** - Optional flag to operate on blocks instead of the document object. ### Examples ```bash docboss q doc.docx '.sections | length' docboss q doc.docx '[.styles.styles[] | select(.kind == "paragraph") | .id]' docboss q doc.docx --blocks -r '.[] | select(.heading_level != null) | .text' # the outline docboss q doc.docx '.diagnostics[] | .message' ``` ``` -------------------------------- ### Render pages with Rust API Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/rendering.md Renders every page of a document using the docboss Rust API. docboss_layout::layout takes an explicit FontDatabase when several documents should share one; layout_document builds one for the document, including its embedded fonts. Each laid-out page holds positioned glyph runs, rectangles, lines and images in points, so a program can inspect geometry without rasterizing. ```rust use docboss_render::Format; fn main() -> Result<(), Box> { let doc = docboss_core::open("report.docx")?; let layout = docboss_layout::layout_document(&doc); for (index, page) in docboss_render::render_pages(&layout, 2.0).into_iter().enumerate() { std::fs::write(format!("page-{}.png", index + 1), page?.encode(Format::Png)?)?; } Ok(()) } ``` -------------------------------- ### AsyncDocument::from_backend Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/remote.md Creates an AsyncDocument from any byte source that implements the Backend trait. ```APIDOC ## AsyncDocument::from_backend ### Description Creates an AsyncDocument from any byte source that implements the Backend trait. ### Method from_backend ### Endpoint AsyncDocument::from_backend(backend: impl Backend) -> Result ### Parameters - **backend** (Backend) - Required - A byte source implementing the Backend trait. ### Request Example ```rust let doc = AsyncDocument::from_backend(backend).await?; ``` ### Response #### Success Response Returns an `AsyncDocument` instance. #### Response Example ```rust let doc = AsyncDocument::from_backend(backend).await?; ``` ``` -------------------------------- ### docboss_zip::write Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Deterministic ZIP writer. ```APIDOC ## write(entries) ### Description Deterministic ZIP writer. ### Parameters - **entries** (list of (name, bytes)) - Required - Entries to write. ### Returns - **Vec** - The ZIP bytes. ### Example ```rust let zip_bytes = docboss_zip::write(vec![("file.txt", b"content".to_vec())]); ``` ``` -------------------------------- ### docboss CLI Source: https://github.com/4thel00z/docboss/blob/master/crates/docboss-cli/skill/SKILL.md Command-line interface for querying DOCX files with jq-like queries. ```APIDOC ## docboss CLI ### Description Command-line interface for querying DOCX files with jq-like queries. ### Usage - `docboss q doc.docx '.sections | length'` - Query sections count. - `docboss q doc.docx '[.styles.styles[] | select(.kind == "paragraph") | .id]'` - Query paragraph style IDs. - `docboss q doc.docx --blocks -r '.[] | select(.heading_level != null) | .text'` - Get outline. - `docboss q doc.docx '.diagnostics[] | .message'` - Query diagnostics messages. - `docboss fonts` - Shows font family resolutions. ``` -------------------------------- ### docboss_aio::AsyncDocument::requests Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Returns the number of requests made. ```APIDOC ## AsyncDocument::requests() ### Description Returns the number of requests made. ### Returns - **u64** - Request count. ### Example ```rust let count = async_doc.requests(); ``` ``` -------------------------------- ### docboss top-level help output Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/cli.md Output of `docboss --help` listing all subcommands and global options. Errors go to stderr prefixed `docboss:`; document and I/O errors exit 1, usage errors and invalid jq programs exit 2. Commands that read a document detect DOCX or DOC from bytes and accept `--password`; some also accept an `http(s)://` URL with range requests. ```text DOCX and DOC parsing, extraction, rendering and conversion Usage: docboss Commands: info Format, metadata, page setup, page count and content counts text Extract plain text md Convert to GitHub-flavored Markdown html Convert to semantic HTML; images are embedded unless --images is given json Dump the document model as JSON q Run a jq program over the JSON form of the document render Lay out and render pages to PNG, PPM, BMP or JPEG (picked by the -o extension) images Export the document's images at their stored size and format parts List the ZIP entries or compound file streams of the container hex Hexdump the whole file or one part of it xml Print an XML part of a DOCX, indented convert Convert to a fresh DOCX, or to .md, .html, .txt or .json, by the -o extension create Create a new DOCX fonts The fonts the document names and the faces they resolve to here diagnostics Everything the lenient reader approximated or dropped skill Install or print the skill document for coding agents tui Explore the document interactively in the terminal help Print this message or the help of the given subcommand(s) Options: -h, --help Print help -V, --version Print version ``` -------------------------------- ### docboss diagnostics: show approximations and drops Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/explorer.md Lists everything the reader approximated or dropped, with the part or stream it came from. The --layout flag adds what layout approximated, such as fonts that fell back or pictures drawn as placeholders. ```bash docboss diagnostics report.docx ``` ```bash docboss diagnostics report.docx --layout ``` -------------------------------- ### docboss xml: view one XML part Source: https://github.com/4thel00z/docboss/blob/master/docs/src/guide/explorer.md Displays a single XML part, indented by default; use --raw to show as stored. ```bash docboss xml report.docx word/styles.xml # one XML part, indented (--raw as stored) ``` -------------------------------- ### docboss_metafile::bitmap::decode Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Decodes a bitmap image. ```APIDOC ## bitmap::decode(bytes) ### Description Decodes a bitmap image. ### Parameters - **bytes** (byte array) - Required - The image bytes. ### Returns - **Bitmap** - The decoded bitmap. ### Example ```rust let bmp = docboss_metafile::bitmap::decode(bytes)?; ``` ``` -------------------------------- ### docboss_output::to_text / write_text Source: https://github.com/4thel00z/docboss/blob/master/docs/src/reference/rust.md Converts a document to plain text with TextOptions. ```APIDOC ## to_text(&Document, &TextOptions) / write_text(&Document, &TextOptions, writer) ### Description Converts a document to plain text with TextOptions. ### Parameters - **document** (Document) - Required - The document to convert. - **options** (TextOptions) - Required - Options for text output. - **writer** (Write) - Required for write_text - Output writer. ### Returns - **String** (for to_text) - The text representation. - **Result** (for write_text) - Result of writing. ### Example ```rust let text = to_text(&doc, &TextOptions::default()); ``` ``` -------------------------------- ### docboss.Document Source: https://github.com/4thel00z/docboss/blob/master/README.md Opens a DOCX or DOC document from a local path, raw bytes, or with an optional password. Provides access to document properties and content extraction methods. ```APIDOC ## docboss.Document ### Description Opens a DOCX or DOC document from a local path, raw bytes, or with an optional password. Provides access to document properties and content extraction methods. ### Constructor - `Document(path)` - Opens a document from a local file path. - `Document(data=raw_bytes)` - Opens a document from raw bytes. - `Document(password="...")` - Optional password for encrypted documents. ### Attributes - `format` (str) - "docx" or "doc" - `metadata.title` (str) - Document title from metadata ### Methods - `extract_text(headers_footers=True)` - Extracts plain text with list labels; options for headers/footers, comments, and notes. - `extract_markdown(images="reference" | "embed" | "omit")` - Extracts GitHub-flavored Markdown. - `extract_html(standalone=True)` - Extracts semantic HTML with images embedded as data URIs. - `blocks()` - Iterates over document blocks with kind, style, heading_level, list_label, and text. - `render(0, scale=2.0)` - Renders a page to PNG bytes; format can be "ppm", "bmp", or "jpeg". - `render_pages()` - Renders every page on all cores. - `images()` - Returns image objects with .name, .content_type, and .data. - `to_docx()` - Returns a fresh DOCX, also for .doc input. ``` -------------------------------- ### docboss.md.to_docx Source: https://github.com/4thel00z/docboss/blob/master/README.md Converts Markdown content to DOCX bytes. Accepts CommonMark and GFM syntax. ```APIDOC ## docboss.md.to_docx ### Description Converts Markdown content to DOCX bytes. Accepts CommonMark and GFM syntax. ### Parameters - `markdown` (str) - Required - Markdown content to convert. ### Returns - bytes - DOCX file bytes. ``` -------------------------------- ### Python synchronous API for docboss Source: https://github.com/4thel00z/docboss/blob/master/README.md Shows the main synchronous Python API for reading, extracting, rendering, and converting documents. Heavy calls release the GIL, so documents can be processed in parallel from Python threads. ```python import docboss doc = docboss.Document("report.docx") # or Document(data=raw_bytes), password="..." print(doc.format, doc.metadata.title) # "docx" or "doc" text = doc.extract_text(headers_footers=True) md = doc.extract_markdown() # images="reference" | "embed" | "omit" html = doc.extract_html(standalone=True) for block in doc.blocks(): # kind, style, heading_level, list_label, text print(block.kind, block.text) png = doc.render(0, scale=2.0) # PNG bytes; format="ppm" | "bmp" | "jpeg" pngs = doc.render_pages() # every page, rendered on all cores imgs = doc.images() # .name, .content_type, .data data = doc.to_docx() # a fresh DOCX, also for .doc input texts = docboss.extract_texts(["report.docx", "legacy.doc"], threads=8) # batch, on Rust threads docx = docboss.md.to_docx("# Notes\n\n- one\n- two\n") # Markdown -> DOCX bytes ```