Last updated
How JPG to PDF Conversion Works
Converting a JPG image to PDF embeds the raster image inside a PDF container. The PDF format (Portable Document Format) was designed by Adobe to present documents consistently across platforms. When you embed a JPG in a PDF, the image data is stored as a compressed stream inside the PDF file structure, wrapped with metadata like page size, orientation, and DPI.
PDF Page Size and Image Scaling
| Page Size | Width (mm) | Height (mm) | At 96 DPI (px) |
|---|---|---|---|
| A4 | 210 | 297 | 794 × 1123 |
| Letter | 215.9 | 279.4 | 816 × 1056 |
| A3 | 297 | 420 | 1123 × 1587 |
| Legal | 215.9 | 355.6 | 816 × 1344 |
Using jsPDF in the Browser
import { jsPDF } from 'jspdf';
async function jpgToPdf(imageFile) {
const url = URL.createObjectURL(imageFile);
const img = new Image();
img.src = url;
await new Promise(r => img.onload = r);
const pdf = new jsPDF({
orientation: img.width > img.height ? 'landscape' : 'portrait',
unit: 'px',
format: [img.width, img.height]
});
pdf.addImage(img, 'JPEG', 0, 0, img.width, img.height);
pdf.save('output.pdf');
URL.revokeObjectURL(url);
}
Quality Considerations
JPG uses lossy compression — each save cycle degrades quality slightly. For best results, use the original high-resolution JPG rather than a screenshot or re-saved copy. If you need text to remain selectable in the PDF, use OCR-based conversion instead of simple image embedding. For scanned documents, 300 DPI is the standard for readable text.
Multiple JPGs can be combined into a single PDF by adding each image as a new page with pdf.addPage() before each pdf.addImage() call.