You have five scanned pages sitting on your desktop and a form that only accepts a single PDF. So you search "images to PDF", pick the first result, and upload your documents to a server you know nothing about.
That last part should bother you more than it does.
Most free image-to-PDF converters send your files to their backend, run the conversion there, and hand you a download. For a meme, fine. For an ID, a payslip, or a signed contract, you just handed a stranger a copy. The good news: converting images to a PDF is a job the browser can do entirely on its own, no upload required. Here is how, both in code and with a tool.
Why do it client-side?
Bundling images into a PDF is pure client work. The browser can already decode a JPG or PNG, draw it to a canvas, and write the bytes of a PDF file. Nothing about that needs a server.
Doing it in the browser buys you three things:
- Privacy. The file never leaves the device. No upload, no server logs, no retention policy to trust.
- Speed. No round trip. A handful of images becomes a PDF in the time it takes to click.
- Offline. Once the page is loaded, it works with the network off.
The only real cost is memory. Very large images held in a canvas use RAM, so a phone will tap out sooner than a laptop. For everyday scans and photos, that ceiling is high enough that you will not hit it.
The DIY way with jsPDF
If you want to build this yourself, jsPDF does the heavy lifting. It creates a PDF in memory and lets you drop an image onto each page.
import { jsPDF } from "jspdf";
function loadImage(url) {
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => resolve(img);
img.onerror = reject;
img.src = url;
});
}
async function imagesToPdf(files) {
const doc = new jsPDF({ unit: "px", format: "a4" });
const pageW = doc.internal.pageSize.getWidth();
const pageH = doc.internal.pageSize.getHeight();
for (let i = 0; i < files.length; i++) {
const url = URL.createObjectURL(files[i]);
const img = await loadImage(url);
if (i > 0) doc.addPage();
doc.addImage(img, "JPEG", 0, 0, pageW, pageH);
URL.revokeObjectURL(url);
}
doc.save("images.pdf");
}
Wire that to a file input and you have a working converter in about 25 lines.
<input type="file" accept="image/*" multiple
onchange="imagesToPdf(this.files)">
Keep in mind what this simple version skips: it stretches every image to fill an A4 page, ignores aspect ratio, and offers no margins, ordering, or compression. Handling all of that well is where a few lines turns into a few hundred.
The no-code way
When you just need the PDF and not a side project, a browser tool that already handles the edge cases is faster. Pixellize Images to PDF runs the whole conversion in your browser, so the files stay on your device, and it covers the parts the snippet above skips.
Drop in your JPG, PNG, or HEIC images and you get:
- Ordering. Drag the thumbnails into the page order you want before you export.
- Page setup. Pick A4, Letter, or fit-to-image, plus portrait or landscape and a margin.
- Compress images. Shrink the output so the PDF is small enough for an upload cap.
- Page numbers and grayscale. Handy for printed handouts and scanned documents.
Then hit Generate PDF and the file downloads. No account, no watermark, nothing uploaded.
A few tips that save reprints
- Order before you export. Reordering pages after the PDF exists means redoing it. Sort the thumbnails first.
- Match the page size to the destination. A4 for most of the world, Letter for the US. Fit-to-image keeps photos edge to edge with no white border.
- Compress for upload limits. Portals that cap PDFs at a few MB are the usual reason a clean export gets rejected. Turn compression on.
- Grayscale scanned text. A scanned document in grayscale is smaller and prints cleaner than a full-color one.
- Watch orientation. Portrait photos on a landscape page get letterboxed. Set the orientation to match the images.
Wrapping up
Converting images to a PDF is one of those tasks that quietly does not need a server, and doing it in the browser keeps your files private and the whole thing instant. Build it with jsPDF when you want it inside your own app, or use a ready tool like Pixellize Images to PDF when you just need the file. Either way, your documents never have to leave your machine.
If you build the DIY version, drop a link in the comments. I am curious how people handle aspect ratio and ordering.

Top comments (0)