JPG to PDF in the browser
js import { PDFDocument } from "pdf-lib"; async function imagesToPdf(files) { const pdf = await PDFDocument.create(); for (const file of files) { const bytes = await file.arrayBuffer(); c
js import { PDFDocument } from "pdf-lib"; async function imagesToPdf(files) { const pdf = await PDFDocument.create(); for (const file of files) { const bytes = await file.arrayBuffer(); c
Online forms often demand “under 100 KB”. Instead of guessing a quality value, binary-search it. js async function compressToTarget(canvas, maxBytes) { const toBlob = (q) => new Promise((r) => c
Before compressing, resize. Dimensions affect file size more than quality does. js async function resize(file, maxSide) { const bmp = await createImageBitmap(file); const scale = Math.min(1, maxSi
Most online PDF mergers upload your files to a server. You can do it entirely client-side with pdf-lib, so private documents never leave the device. js import { PDFDocument } from "pdf-lib"; async fu