# DjVu module for johnmcm.com The WebAssembly module behind johnmcm.com's DjVu Viewer (/open-file/djvu) and DjVu to PDF converter (/djvu-to-pdf). It is [djvu-rs](https://github.com/matyushkin/djvu-rs) 0.42.0 by Mikhail Matyushkin, MIT licensed and written from the public DjVu v3 specification (no DjVuLibre or other GPL code), compiled with wasm-pack. djvu-rs's own browser bindings (WasmDocument, WasmPage: rendering and the text layer) are used unchanged; its npm build lacks the PDF export and the bookmarks, so the small crate in this folder (`src/lib.rs`) adds `export_pdf` and `outline_json`. This folder publishes exactly what is built: - `Cargo.toml`, `Cargo.lock` and `src/lib.rs`: the crate, with djvu-rs pinned to 0.42.0. The Dockerfile downloads djvu-rs from crates.io and checks it against the checksum in Cargo.lock. - `patches/pdf-text-and-links.patch`: the one change made to djvu-rs. Its PDF text layer was set in Helvetica with WinAnsi encoding, and every character outside ASCII became "?", so a French, Russian or Chinese book's PDF could not be searched or copied from. The patch sets that invisible text in an embedded, glyphless Type0 font (Identity-H, each character written as its UTF-16 code unit, with a ToUnicode map), as Tesseract and OCRmyPDF do, and writes non-ASCII bookmark titles as UTF-16. It also makes a link to another page of the book ("#12") go to that page, through a named destination per page; djvu-rs wrote it as a web link to "#12", which goes nowhere. - `font/make_glyphless.py` and `font/glyphless.ttf`: the font the patch embeds, two empty glyphs half an em wide, made with fontTools for this site (public domain). - `src/worker.mjs`: the worker the pages talk to. - `Dockerfile` and `build.ps1`: the build, with the Rust image pinned by digest. Run `build.ps1` with Docker Desktop running; the module goes to `frontend/vendor/local/djvu@2/`. The module is loaded as separate files by the page, so it can be replaced with one built from modified source.