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

Bindings for other languages

kakemono is a Rust library; besides Python (python/), it is packaged for:

LanguagePackageDirectoryHow it calls Rust
JavaScript, TypeScript (Node.js, Bun)@kakemono/node (npm)bindings/node/napi-rs 3, prebuilt for 8 platforms
JavaScript, TypeScript (browsers, workers, edge)@kakemono/wasm (npm, experimental)bindings/wasm/wasm-bindgen
Java 17+, Kotlinio.github.iamcaominhtien:kakemono (+ kakemono-langchain4j); the native library is downloaded from the GitHub releasebindings/jvm/JNI
C#, F# (.NET 8+)Kakemono (NuGet)bindings/dotnet/P/Invoke over the C ABI
C, C++include/kakemono.h + kakemono_ffibindings/c/the C ABI itself

Why these: LANGUAGE-BINDINGS.md (in Vietnamese: the market survey and the comparison with Kreuzberg). Other languages can call the command line.

Every binding has the same shape as the Python package: a Document is read and analysed once (from bytes, a file, an http(s) address or an arXiv id), then written to any output: HTML (4 modes), Markdown, editable JSON, LaTeX, Typst, Word, EPUB, a PDF (Word documents, workbooks, EPUB books, web pages), chunks for retrieval, or the document structure. The options have the same names and defaults everywhere (camelCase: imageDir, inlineImages, maxTokens, …), and a wrong option is refused with its name (imageDir does not apply to epub). Each package’s README shows its API: Node, WebAssembly, JVM, .NET.

Layout

bindings/                 a Cargo workspace of its own (not the root crate's)
  core/    kakemono-bindings   the façade: Document, OpenOptions, RenderOptions, Output, Error
  c/       kakemono-c          the C ABI (library kakemono_ffi), include/kakemono.h (cbindgen)
  node/    kakemono-node       napi-rs; index.js and index.d.ts are generated by `napi build`
  jvm/native/ kakemono-jni     JNI; jvm/ is the Maven project (Java API, LangChain4j, natives)
  wasm/    kakemono-wasm       its own workspace (wasm32 only, no default features)
  dotnet/                      C#, over the C ABI

bindings/core holds every check and default, so that the bindings stay thin; a new option goes there first (RenderOptions, Target::options), then into each binding’s typed options.

Behaviour shared by every binding

  • Threads. The work runs on a thread of kakemono’s own with a 16 MB stack (guarded in bindings/core): reading a PDF recurses deeply, and the threads of a JVM, of .NET’s pool or of libuv have about 1 MB. A Document can be written from several threads at once; closing it waits for the calls running on it. jobs (default: one per core) is per document: a server converting several documents at once should set it to 1 or 2.
  • Errors have a kind: a wrong argument or option, a document that cannot be read or written so, or a bug of kakemono (a panic, caught: no panic crosses into the host; except in WebAssembly, where a panic aborts the module).
  • Fonts. Laying out pages (a PDF of a Word document or a workbook, the hard modes of a Word document) needs a font: those installed, those embedded in the document, the folders of KAKEMONO_FONT_DIRS, or one given with addFont / add_font (WebAssembly has no other). Without any, those outputs fail with an error (Word’s medium page is then the friendly one).
  • Stopping a call. Every call can be stopped from another thread, or after a time limit (kakemono’s CancelToken): Node takes signal (an AbortSignal) and timeout in the options of each call, the JVM a CancelToken and a timeout, .NET a CancellationToken, C a KkCancel. The call stops soon after (normally within a page; a download within its next chunk) with an error of its own kind (AbortError/TimeoutError, CANCELLED/TIMED_OUT, OperationCanceledException, KK_ERROR_CANCELLED/KK_ERROR_TIMED_OUT), and the document stays usable. Not in WebAssembly: its work is synchronous, and stopping would abort the module. A call that waits for another call’s page layout of the same Word document (its hard and medium modes, its PDF) stops only once that layout ends.

Performance

Measured on 4 cores (2026-11-28): the 8 test papers, a Word document and a workbook, each read from bytes and written as Markdown with jobs = 1, best of 3 runs; every binding gives the same Markdown, byte for byte.

Called fromRustCNodeJava.NETWebAssembly (Node)
Seconds6.776.677.017.436.938.42
Against Rust1.000.981.041.101.021.24
  • Concurrency: the 8 papers at once take 2.7 s (Node, Java) to 3.6 s (.NET) instead of about 7 s. Node runs at most one conversion per core at once (KAKEMONO_MAX_CONCURRENCY): 24 outputs of the GPT-4 paper at once peak at 754 MB instead of 1.6 GB, in the same time.
  • Memory: 2000 rounds of open, five outputs and close (a Word document), and 40 to 120 rounds on the LIGO paper, stay flat in C, Node, Java, .NET and WebAssembly, also when Java and .NET documents are left to the garbage collector instead of being closed.
  • WebAssembly runs in Chromium (the page and a Web Worker) and handles the 100-page GPT-4 paper in the hard mode (45 MB of HTML, 442 MB of memory).

Building and testing

cd bindings
cargo test --release -p kakemono-bindings -p kakemono-c       # the façade and the C ABI
(cd c && cbindgen --config cbindgen.toml --output include/kakemono.h)   # after changing the ABI
(cd node && npm ci && npx napi build --platform --release && npm test && npm run typecheck)
(cd wasm && ./build.sh && npm test)                           # needs wasm-bindgen-cli 0.2.130
cargo build --release -p kakemono-jni && mvn -f jvm/pom.xml verify
cargo build --release -p kakemono-c && dotnet test dotnet/Kakemono.sln

The Bindings workflow (.github/workflows/bindings.yml) runs these on every pull request.

Releases

After each release (the Release workflow), the Bindings workflow builds the native libraries for Linux (x86_64, arm64; glibc 2.17 and musl), macOS (x86_64, arm64) and Windows (x86_64, arm64), sets every package’s version from the tag (scripts/set-bindings-version.py), and assembles the npm, Maven and NuGet packages (kept as workflow artifacts). It publishes them only when the repository variable BINDINGS_PUBLISH is true, with these secrets:

RegistrySecretsSet up once
npmNPM_TOKEN (an automation token)the kakemono organization on npmjs.com, for the @kakemono/ scope
Maven CentralMAVEN_CENTRAL_USERNAME, MAVEN_CENTRAL_PASSWORD (a Central Portal token), MAVEN_GPG_PRIVATE_KEY, MAVEN_GPG_PASSPHRASEthe namespace io.github.iamcaominhtien, verified on central.sonatype.com; a GPG key published on a key server
NuGetnone (trusted publishing)a trusted publishing policy on nuget.org (account iamcaominhtien): GitHub Actions, repository iamcaominhtien/kakemono, workflow file bindings.yml

Each publishing job runs in an environment named after its registry (npm, npm-wasm, maven-central, nuget), so each publication shows as a deployment on the repository’s page, with a link to the published version (as pypi does for the Python package). The NuGet policy must leave its environment empty, or name nuget.

Maven Central is published to only by hand, since its monthly limits allow about 7 releases an organization and this repository releases each pull request: in the Actions tab, run the Bindings workflow on main with Also publish the Java packages to Maven Central ticked (gh workflow run bindings.yml --ref main -f maven=true). It publishes the version of main, which must have been released (its tag v<version> exists). Every release still puts the native JARs on its GitHub release, and the other registries are published as usual.

The JNI libraries are not uploaded to Maven Central: one release of them (8 platforms, about 120 MB) is above Central’s monthly publishing limits (about 78 MB, 1,167 files, 7 releases an organization). The Maven job puts them on the GitHub release as kakemono-native-<version>-<platform>.jar, writes their SHA-256 into the kakemono JAR (natives.properties), and the Java code downloads the one it needs (bindings/jvm/README.md, “Native library”). The upload to Central also leaves out the SHA-256 and SHA-512 checksum files, which count against the limits.

A version already published is skipped, so the workflow can be run again by hand. On Maven Central the upload is validated, then waits to be published by hand on central.sonatype.com, unless the repository variable BINDINGS_MAVEN_AUTO_PUBLISH is true. Run the first release with BINDINGS_PUBLISH unset: the packages are then only built, as artifacts of the workflow run.