PDF Perfect compresses files entirely in-browser using pdf.js and Web Workers
Developer Arun built PDF Perfect, a browser-based PDF compressor that processes files entirely on the user's device without uploading them to any server. The tool uses Mozilla's pdf.js to render each PDF page onto an OffscreenCanvas, then encodes it as a JPEG using the browser's native canvas API before assembling a new PDF with pdf-lib. All processing runs inside a Web Worker to avoid blocking the main thread, with results transferred back efficiently using ArrayBuffer transfers to prevent memory duplication. Three compression presets pair JPEG quality with render scale, while a Target File Size mode automatically tries progressively smaller settings until the output meets a user-specified size limit. The approach works best on scan-heavy or image-rich PDFs but involves a trade-off for text documents, which lose sharpness due to rasterisation.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in