How to Convert JPG to PDF Without Losing Quality
Converting images to PDF often introduces double compression and quality loss. Here's how to do it right — preserving every pixel.
The typical JPG-to-PDF converter takes your image, runs it through JPEG compression again, and embeds the result. The output looks fine at a glance but zooms soft, and you've permanently degraded your source. There's a better way.
Why Re-Encoding a JPEG Destroys Quality
JPEG uses lossy compression. Every time you re-encode, you add another generation of artefacts — even at quality 95. A JPEG that's been through three converters will be noticeably softer than the original, with visible blocking artefacts around high-contrast edges.
The correct approach is to embed the JPEG bytes directly into the PDF stream without re-encoding. The PDF format natively supports JPEG-compressed image streams — you can store the original bytes as-is, meaning zero quality loss.
// Embed JPEG bytes directly into PDF — no recompression
import { PDFDocument } from 'pdf-lib';
const pdfDoc = await PDFDocument.create();
const jpgBytes = new Uint8Array(await file.arrayBuffer()); // original bytes
// embedJpg stores the original JPEG stream — no quality loss
const jpgImage = await pdfDoc.embedJpg(jpgBytes);
// Page sized exactly to the image (72 DPI = 1px per point in PDF units)
const page = pdfDoc.addPage([jpgImage.width, jpgImage.height]);
page.drawImage(jpgImage, { x: 0, y: 0, width: jpgImage.width, height: jpgImage.height });
const pdfBytes = await pdfDoc.save();Setting the Right Page Size for Print
PDF page sizes are in points (1 point = 1/72 inch). For a photo intended to print at A4 at 300 DPI, the source image needs to be 2480×3508 pixels. Scaling a smaller image up in the PDF adds interpolated pixels — it won't be sharp.
- ●Letter (8.5×11″) at 300 DPI: 2550×3300px source
- ●A4 (210×297mm) at 300 DPI: 2480×3508px source
- ●A5 (148×210mm) at 300 DPI: 1748×2480px source
- ●Screen only: any size — DPI doesn't affect on-screen display
For multi-page PDFs (scanned documents, photo books), embed each JPEG image using the same lossless approach. The file size will be similar to the sum of the original images.
PNG and WebP Sources
PNG files are lossless — any conversion to JPEG is the first lossy step, so choose quality carefully. WebP is not a native PDF image format and must be converted to JPEG or PNG first. Our Image to PDF converter embeds JPEG data directly without re-encoding.
Ready to try it?
All tools run entirely in your browser — no uploads, no account required.
Image to PDF