Certificates & Attendance9 min read•November 11, 2026 at 01:00 AM IST

Web Worker Vector PDF Generation: Batch-Exporting 1,500 Certificates Without Crashing

Generating hundreds of PDFs in the browser usually causes tab freezing and out-of-memory crashes. Here is how Spark uses Web Workers and pdf-lib for lightning-fast exports.

A

Aryan Deshmukh

Platform Architecture & Engineering

The Challenge of Client-Side PDF Generation

Server-side PDF rendering using headless Chromium (Puppeteer) or Python WeasyPrint is notoriously expensive and slow. Spinning up dozens of cloud servers to generate 2,000 PDFs for a free student fest creates unsustainable cloud hosting bills.

Client-side rendering in the attendee's browser is free and scalable—if implemented correctly.

However, naive browser implementations using jsPDF or HTML2Canvas on the main thread cause immediate browser tab freezing and memory crashes on batches larger than 50 files.

Here is the exact Web Worker architecture used by Spark to batch-render 1,500 vector certificates in under 60 seconds.

---

1. Off-Thread Rendering Pipeline

Spark isolates all rendering logic inside a dedicated Web Worker (src/workers/certificate-batch.worker.ts):

[ Main UI Thread ] ──(PostMessage: Roster + Template)──> [ Web Worker (pdf-lib) ]
        │                                                         │
   [ UI Remains ]                                         [ Renders Vector PDF ]
 [ Smooth & Active ] <──(Transferable ArrayBuffer)─────── [ OffscreenCanvas ]

Key Architectural Safeguards: 1. Zero Main-Thread Blocking: The browser UI stays at 60 FPS. Organizers can navigate tabs, view live progress bars, and cancel exports at any time. 2. Transferable Objects (`[buffer]`): Instead of cloning massive byte arrays across thread boundaries, Spark transfers ownership of the underlying ArrayBuffer, eliminating garbage collection stutter. 3. True Vector Text Rendering: Unlike raster image screenshots, pdf-lib embeds real vector fonts. Text remains crisp and searchable even at 800% zoom.

---

2. Export Packaging Formats

Organizers can choose from three export targets: `png-zip`: Individual high-resolution PNG images zipped into a single download. `pdf-zip`: Individual vector PDF files packaged in a ZIP archive for bulk printing. `merged-pdf`*: A single multi-page print-ready document containing all 1,500 certificates sequentialized for industrial campus print shops.

With real-time throughput metrics (certificates rendered per second and estimated time remaining), committee heads can export festival records with total confidence.

Frequently Asked Questions

Why do browsers crash when generating hundreds of PDF certificates?

Main-thread JavaScript execution blocks the browser's UI rendering loop and garbage collection during heavy canvas/PDF operations, leading to out-of-memory browser tab crashes.

How does Spark's Web Worker architecture solve memory bottlenecks?

Spark offloads rendering to src/workers/certificate-batch.worker.ts, utilizing transferable ArrayBuffers to pass completed binary PDF buffers to the main thread with zero-copy memory overhead.

Topics covered in this guide:

#Web Workers#pdf-lib#Performance#Vector PDF#Browser Architecture

Next Step: Discover PDF Engine Architecture

Zero commission on tickets. Direct UPI payments to your club account. Instant gate QR passes and automated certificate delivery.

Discover PDF Engine Architecture →
Keep Reading

Related Event Guides