Skip to content

Repository files navigation

TurboParse SDK

TurboParse SDK is a browser-first npm package that turns PDF bytes into typed, layout-aware document data without sending the document to a server. It uses:

  • Poppler compiled to WebAssembly for PDF tokenization;
  • ONNX Runtime Web for the document model;
  • an AssemblyScript WebAssembly core for page-aware CRF/Viterbi decoding.

Install

npm install @turboparse/sdk

Parse a PDF

import { TurboParse } from "@turboparse/sdk";

const parser = await TurboParse.create();
const result = await parser.parse(file);

console.log(result.pages);
console.log(parser.toMarkdown(result));

await parser.dispose();

parse accepts a File, Blob, ArrayBuffer, or typed array. The returned object contains page geometry, semantic token labels, font information, bounding boxes, reading order, and table probabilities.

Host assets on a CDN

The default build loads the trained model from TurboParse's GitHub LFS-backed repository. Poppler and the AssemblyScript core ship inside the npm package, while ONNX Runtime Web binaries default to jsDelivr. All external runtime paths can be configured, so production deployments can host the model on their own CDN:

const parser = await TurboParse.create({
  modelBaseUrl: "https://cdn.example.com/turboparse/model/",
  popplerModuleUrl: "https://cdn.example.com/turboparse/poppler/pdf2html.js",
  onnxWasmBaseUrl: "https://cdn.example.com/onnxruntime/",
  executionProviders: ["wasm"],
});

Your bundler or deployment must serve .wasm files as application/wasm and preserve the relative files inside assets/poppler/.

Direct utilities

The package also exports parsePopplerXml, buildPopplerFeatureMatrix, toMarkdown, and toHtml for custom pipelines and testing.

Runtime scope

PDF parsing is browser-first and requires Worker, DOMParser, and fetch. The pure serializers and generated AssemblyScript binding can also run in Node. OCR and the frontend's bank-statement-specific view are intentionally outside the initial SDK boundary.

License

GPL-2.0-or-later. The bundled Poppler WebAssembly runtime is derived from Poppler and must be distributed in compliance with the GPL, including the corresponding-source obligations described by that license.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages