Image to PDF
Combine one or more images into a downloadable PDF. Each image becomes a PDF page scaled to fit.
Back to all tools on ToolForge
Upload one or more images to combine them into a PDF.
Selected Images
About Image to PDF
This Image to PDF tool converts images (PNG, JPEG, WebP) into PDF pages using client-side JavaScript processing. Each uploaded image is added as a separate PDF page and automatically scaled to fit within the page margins while preserving the original aspect ratio.
The conversion uses the jsPDF library to embed image data directly into the PDF structure, then generates a downloadable file without any server upload or processing.
PDF Image Embedding Process
When an image is added to a PDF, the following steps occur:
- Image Loading: The image file is read as a Data URL (base64-encoded binary data)
- Format Detection: The MIME type prefix (data:image/png or data:image/jpeg) determines the PDF encoding method
- Dimension Calculation: Original width and height are measured to compute aspect ratio
- Page Scaling: The image is scaled to fit the target page size while maintaining proportions
- PDF Object Creation: A new page is added and the image is embedded as an XObject
- File Generation: All objects are serialized into the binary PDF format with proper headers and cross-reference tables
Supported Image Formats
| Format | PDF Encoding | Compression | Transparency | Best For |
|---|---|---|---|---|
| JPEG/JPG | DCTDecode | Lossy | No | Photographs, natural images |
| PNG | FlateDecode | Lossless | Yes | Screenshots, graphics, text images |
| WebP | Converted to JPEG/PNG | Varies | Yes (lossy/lossless) | Modern web images |
| GIF | Converted (not recommended) | LZW | Yes | Simple graphics (limited support) |
Page Size Reference
| Size | Dimensions (mm) | Dimensions (inches) | Dimensions (points) |
|---|---|---|---|
| A4 (default) | 210 x 297 | 8.27 x 11.69 | 595 x 842 |
| Letter | 216 x 279 | 8.5 x 11 | 612 x 792 |
| Legal | 216 x 356 | 8.5 x 14 | 612 x 1008 |
| A3 | 297 x 420 | 11.69 x 16.54 | 842 x 1190 |
| Tabloid | 279 x 432 | 11 x 17 | 792 x 1224 |
Aspect Ratio Preservation
To prevent image distortion, the tool calculates a uniform scale factor:
// Calculate scale to fit image within page bounds const maxWidth = pageWidth - (2 * margin); const maxHeight = pageHeight - (2 * margin); const scaleX = maxWidth / imageWidth; const scaleY = maxHeight / imageHeight; const scale = Math.min(scaleX, scaleY); // Use smaller scale const renderWidth = imageWidth * scale; const renderHeight = imageHeight * scale; const x = (pageWidth - renderWidth) / 2; // Center horizontally const y = (pageHeight - renderHeight) / 2; // Center vertically
Common Use Cases
- Document Scanning: Combine multiple scanned pages into a single PDF file
- Photo Albums: Create printable photo collections or portfolios
- Screenshot Reports: Document bugs or workflows with sequenced screenshots
- Receipt Organization: Compile expense receipts for reimbursement
- Art Portfolios: Assemble artwork images for submission or sharing
- Print Preparation: Convert digital images to print-ready PDF format
- Archive Creation: Preserve visual content in a standardized, long-term format
PDF File Size Considerations
PDF file size depends on image resolution, format, and compression:
- High-resolution images: Larger file sizes but better print quality. Consider downsampling for screen-only viewing.
- JPEG quality: Lower quality (60-80%) reduces file size significantly with minimal visible loss for photos.
- PNG optimization: PNG files can be large for photographs but are efficient for graphics with few colors.
- Page count: Each additional page adds overhead but the image data dominates total size.
jsPDF Library Usage
// Initialize PDF with A4 size, portrait orientation, points unit
const pdf = new jsPDF('p', 'pt', 'a4');
// Add first image
pdf.addImage(imageData, 'PNG', x, y, width, height);
// Add additional pages
pdf.addPage();
pdf.addImage(nextImageData, 'JPEG', x, y, width, height);
// Save the generated PDF
pdf.save('document.pdf');
Browser Compatibility
This tool uses modern JavaScript features and requires:
- File API: For reading uploaded image files (all modern browsers)
- Blob API: For generating downloadable PDF files
- Promise support: For async image loading
- Canvas API: Used internally by jsPDF for image processing
Tested on Chrome 60+, Firefox 55+, Safari 11+, Edge 79+.
Frequently Asked Questions
- How does client-side PDF generation work?
- Client-side PDF generation uses JavaScript libraries like jsPDF to create PDF documents directly in the browser. The library encodes image data (PNG/JPEG) as binary streams within the PDF structure, writes PDF objects (pages, images, resources), and generates the final binary PDF file for download. No server processing is required.
- What image formats are supported for PDF conversion?
- PDF supports JPEG and PNG natively. JPEG uses DCTDecode compression (lossy, smaller files). PNG uses FlateDecode (lossless, preserves transparency). WebP and other formats are typically converted to JPEG/PNG before embedding. Most PDF generators auto-detect format from the image data URI prefix.
- How are images scaled to fit PDF pages?
- Images are scaled using aspect ratio preservation: calculate the ratio between image dimensions and page dimensions, then use the smaller ratio for both width and height. This prevents distortion. The formula is: scale = min(pageWidth / imgWidth, pageHeight / imgHeight). Center the result using (pageWidth - scaledWidth) / 2.
- What is the PDF page size standard?
- A4 (210 x 297 mm or 595 x 842 points at 72 DPI) is the international standard. Letter (8.5 x 11 inches or 612 x 792 points) is common in North America. PDF uses points as the internal unit (1/72 inch). jsPDF and other libraries support A4, Letter, Legal, and custom sizes with portrait or landscape orientation.
- How does PDF handle image quality and compression?
- PDF preserves the original image quality when embedding. JPEG images retain their compression level. PNG images remain lossless. Some PDF generators allow re-compression to reduce file size. For photographs, JPEG at 80-90% quality offers good balance. For screenshots and graphics, PNG preserves sharp edges and text.
- What are the use cases for image to PDF conversion?
- Common uses: combining scanned documents into single files, creating photo albums or portfolios, preparing screenshots for reports, converting diagrams to shareable documents, archiving visual content in standard format, creating printable materials from digital images, and preparing submission packages that require PDF format.