Home  β€Ί  Playgrounds  β€Ί  Medical 800-page

800-page Medical Report β€” Web Worker Showcase

Generates a fictitious, fully synthetic medical report (anonymized data, deterministic seeded RNG) demonstrating how pdfnative scales to large documents off the main thread. Pages contain headers, footers, patient summaries, longitudinal vital signs tables, and laboratory results β€” typical real-world clinical document patterns.

Privacy: all patient names, IDs, dates, and values are generated client-side from a seeded random number generator. No real PHI is ever sent over the network.

Idle 0%
Mode
β€”
Bytes streamed
β€”
Chunks
β€”
Elapsed
β€”

What this showcase demonstrates

Code structure

// Main thread
const worker = new Worker(workerBlobUrl, { type: 'module' });
worker.onmessage = (e) => {
  if (e.data.type === 'progress') updateProgress(e.data);
  if (e.data.type === 'done') downloadPdf(e.data.bytes);
};
worker.postMessage({ pageCount: 800, tagged: true, seed: 42 });

// Inside the worker
import { buildDocumentPDFStream, concatChunks } from 'https://esm.sh/pdfnative';
const blocks = synthesizePatientReport(seed, pageCount);
const chunks = [];
for await (const chunk of buildDocumentPDFStream({ title, blocks }, {}, { chunkSize: 65536 })) {
  chunks.push(chunk);
  postMessage({ type: 'progress', bytes: chunks.reduce((s, c) => s + c.length, 0) });
}
postMessage({ type: 'done', bytes: concatChunks(chunks) }, [bytes.buffer]);

View this page’s source on GitHub β†’