Skip to main content

Worker Pool

Render pages concurrently across Web Workers to keep the main thread responsive.

import { WorkerPool } from "pdfnova/lite";

Setup

const pool = new WorkerPool(4); // 4 workers
await pool.init({ tier: "lite" });

Render Multiple Pages

const images = await pool.renderPages([0, 1, 2, 3], { scale: 2 });
// images: ImageData[]

Cleanup

pool.destroy();

When to Use

  • Large documents where rendering many pages sequentially would block the UI
  • Thumbnail generation for all pages at once
  • Print preview rendering all pages in parallel

For most use cases (single-page rendering, lazy scrolling), the main-thread API is sufficient. The VirtualRenderer handles lazy rendering without workers.