Urgent.News

What's breaking now, across thousands of outlets.

Tech

Merge and compress PDFs in the browser with pdf-lib and PDF.js (no server, no upload)

Most "free PDF tools" upload your file to a server, process it, and send it back. For a contract, a bank statement or a scanned ID, that is a real privacy cost, and it isn't necessary. Modern browsers can do most everyday PDF jobs locally. In this post I'll show the two operations people ask for most, merge and compress , using two libraries: pdf-lib to create and modify PDF documents. PDF.js…

Both PDF-lib and PDF.js enable merging and compressing PDFs directly in a user's web browser, eliminating the need for server-side processing or file uploads. This approach preserves user privacy and avoids potential security risks associated with transmitting sensitive documents to external servers.

Merging PDFs is a straightforward task using pdf-lib. The process involves loading each input file, copying its pages into a new PDF document, and saving the combined output. The function mergePdfs accepts an array of file objects, loads each file, and appends its pages to the output document. The resulting merged PDF is then saved using object streams to optimize its size.

Compressing a PDF primarily focuses on image content, as vector graphics and text are inherently compact. pdf-lib provides the useObjectStreams flag to enable object stream compression, which reduces the file size by about 5-15% for text-heavy PDFs. However, this method cannot re-encode embedded images. To achieve significant compression of scanned documents, rasterization is required.

This involves rendering each page to a canvas, encoding it as a JPEG with a reduced quality setting, and creating a new PDF containing these compressed images. This approach is lossy, meaning some image quality is sacrificed, but it can result in substantial file size reductions.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

AeroLoop — The Air-Quality Agent That Keeps Its Own Ghosts

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine What I Built AeroLoop — The Air-Quality Agent That Keeps Its Own Ghosts 👻 What if an AI agent…

  • AeroLoop predicts London's PM2.5 levels using weather features and linear correction.
  • AI agent stores failed predictions as historical ghosts for future learning.
  • Holdout set prevents future data leakage during model evaluation.

12 Best Project Management Tools (2026): Tested on Windows & Ranked

This is a republished copy of our ranking. The original, with a team-cost calculator, a slider to re-weight the scores and every screenshot, lives at benchtested.app/best/project-management .

  • ClickUp scored 7.4/10 in project-management test on Windows
  • Notion was fastest app, loading 5 seconds, 200 rows in 10
  • Notion free plan lacks automations and AI task management

More from Saturday 31 October →