Skip to content

WASM Use Cases

EdgeParse WASM runs the full Rust PDF extraction engine directly in the browser. For production apps with progress UI and optional OCR, prefer @edgeparse/web (odl-bench WASM overall 0.854, TEDS 0.776). Below are patterns with the low-level edgeparse-wasm API and the product SDK.

Extract structured chunks from PDFs in the browser, then send only the text to your embedding API. The full PDF never leaves the user’s device.

import { EdgeParse } from '@edgeparse/web';
const ep = await EdgeParse.create({ models: 'lazy', ocr: 'small' });
async function extractChunksForRAG(file: File) {
const job = ep.parse(file, { format: 'json', tableMethod: 'cluster' });
const result = await job.result;
const doc = JSON.parse(result.json!);
const chunks = doc.kids
.filter((el: any) => ['paragraph', 'heading'].includes(el.type))
.map((el: any) => ({
text: el.content,
page: el['page number'],
type: el.type,
bbox: el['bounding box'],
}));
const response = await fetch('/api/embed', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ chunks: chunks.map((c: any) => c.text) }),
});
return { chunks, embeddings: await response.json(), quality: result.quality };
}
import init, { convert_to_string } from 'edgeparse-wasm';
await init();
async function extractChunksForRAG(file: File) {
const bytes = new Uint8Array(await file.arrayBuffer());
const doc = JSON.parse(convert_to_string(bytes, 'json'));
const chunks = doc.kids
.filter((el: any) => ['paragraph', 'heading'].includes(el.type))
.map((el: any) => ({
text: el.content,
page: el['page number'],
type: el.type,
bbox: el['bounding box'],
}));
const response = await fetch('/api/embed', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ chunks: chunks.map((c: any) => c.text) }),
});
return { chunks, embeddings: await response.json() };
}

Why WASM: Your users upload sensitive documents (contracts, medical records, financials). With WASM, the PDF stays on-device and only extracted text goes to your API. No ML stack required for born-digital PDFs; optional in-browser OCR for image tables.

Build a web app where users drag-and-drop PDFs and instantly see structured output. No file uploads, no server queue, no processing delays.

import { EdgeParse } from '@edgeparse/web';
const ep = await EdgeParse.create({ models: 'off' }); // born-digital only
const dropZone = document.getElementById('drop-zone')!;
dropZone.addEventListener('drop', async (e) => {
e.preventDefault();
const file = e.dataTransfer?.files[0];
if (!file || file.type !== 'application/pdf') return;
const job = ep.parse(file, { format: 'all' });
job.on('progress', (p) => console.log(p.label, p.fraction));
const result = await job.result;
document.getElementById('markdown-output')!.textContent = result.markdown ?? '';
document.getElementById('json-output')!.textContent = result.json ?? '';
});

Why WASM: Zero latency. No loading spinners, no “processing…” modals. Results appear instantly.

Build a Progressive Web App that works without internet. Cache the WASM binary (and optionally OCR models via OPFS) with a service worker.

service-worker.ts
const CACHE_NAME = 'edgeparse-v1';
self.addEventListener('install', (event: ExtendableEvent) => {
event.waitUntil(
caches.open(CACHE_NAME).then(cache =>
cache.addAll([
'/',
'/index.html',
'/edgeparse_wasm_bg.wasm',
'/edgeparse_wasm.js',
])
)
);
});
self.addEventListener('fetch', (event: FetchEvent) => {
event.respondWith(
caches.match(event.request).then(cached => cached || fetch(event.request))
);
});

Why WASM: No server dependency. Once cached, the entire extraction pipeline works offline.

Deploy PDF conversion tools on GitHub Pages, Netlify, or Vercel with zero backend costs. The entire application is client-side JavaScript + WASM.

<!DOCTYPE html>
<html>
<head><title>PDF to Markdown Converter</title></head>
<body>
<input type="file" id="pdf" accept=".pdf" />
<pre id="output"></pre>
<script type="module">
import init, { convert_to_string } from './edgeparse_wasm.js';
await init();
document.getElementById('pdf').addEventListener('change', async (e) => {
const file = e.target.files[0];
const bytes = new Uint8Array(await file.arrayBuffer());
document.getElementById('output').textContent =
convert_to_string(bytes, 'markdown');
});
</script>
</body>
</html>

Why WASM: Free hosting. No compute costs, no API rate limits, no scaling concerns.

Build a Chrome or Firefox extension that adds “Extract as Markdown” or “Copy as JSON” to any PDF viewed in the browser.

content-script.ts
import init, { convert_to_string } from 'edgeparse-wasm';
chrome.runtime.onMessage.addListener(async (msg) => {
if (msg.action !== 'extract-pdf') return;
await init();
const response = await fetch(window.location.href);
const bytes = new Uint8Array(await response.arrayBuffer());
const markdown = convert_to_string(bytes, 'markdown');
await navigator.clipboard.writeText(markdown);
chrome.runtime.sendMessage({ action: 'extracted', length: markdown.length });
});

Why WASM: Runs in the extension context without needing a native binary or server connection.

Extract tables from PDFs and convert them to CSV or array data for spreadsheet applications or data analysis tools. Optional in-browser OCR improves image-backed tables.

import { EdgeParse } from '@edgeparse/web';
const ep = await EdgeParse.create({
models: 'lazy',
ocr: 'small',
onBeforeDownload: async (model) =>
confirm(`Download ${model.id} (~${(model.bytes / 1e6).toFixed(1)} MB)?`),
});
async function extractTables(file: File) {
const result = await ep.parse(file, { format: 'json', tableMethod: 'cluster' }).result;
const doc = JSON.parse(result.json!);
return doc.kids
.filter((el: any) => el.type === 'table')
.map((el: any) => ({
page: el['page number'],
rows: el.rows,
bbox: el['bounding box'],
}));
}

Why WASM: Process hundreds of invoices, receipts, or reports in the browser without uploading sensitive financial data.

Add PDF extraction as a feature in your web application without provisioning additional backend compute. Each user’s browser handles its own processing.

import { EdgeParse } from '@edgeparse/web';
let client: EdgeParse | null = null;
export async function initEdgeParse() {
if (client) return client;
client = await EdgeParse.create({ models: 'lazy', ocr: 'small' });
return client;
}
export async function parsePdf(file: File, format: 'markdown' | 'json' = 'markdown') {
const ep = await initEdgeParse();
return (await ep.parse(file, { format }).result);
}

Why WASM: Zero marginal compute cost per user. No backends to scale, no API quotas to manage.

  • First load: ~4 MB WASM download, compiled and cached by the browser
  • OCR models: optional; downloaded only with consent (onBeforeDownload) and cached in OPFS/Cache API
  • Subsequent loads: Instant (from browser cache)
  • Parsing speed: Depends on PDF complexity; most born-digital documents parse in well under a second
  • Memory: Uses browser memory; very large PDFs (100+ pages) may need attention
  • Threading: Single-threaded in WASM (no Rayon parallelism); for batch processing, use the native CLI or Python/Node SDK
ScenarioRecommendation
Batch processing (100+ documents)Use CLI or Python SDK with Rayon parallelism
Server-side pipelineUse Python or Node.js SDK
Very large PDFs (500+ pages)Use native SDK for better memory handling
CI/CD integrationUse CLI binary
Single-document, user-facingUse @edgeparse/web / WASM

See EdgeParse WASM in action: edgeparse.com/demo/