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

More in PDF & Export

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:

  1. Image Loading: The image file is read as a Data URL (base64-encoded binary data)
  2. Format Detection: The MIME type prefix (data:image/png or data:image/jpeg) determines the PDF encoding method
  3. Dimension Calculation: Original width and height are measured to compute aspect ratio
  4. Page Scaling: The image is scaled to fit the target page size while maintaining proportions
  5. PDF Object Creation: A new page is added and the image is embedded as an XObject
  6. File Generation: All objects are serialized into the binary PDF format with proper headers and cross-reference tables

Supported Image Formats

FormatPDF EncodingCompressionTransparencyBest For
JPEG/JPGDCTDecodeLossyNoPhotographs, natural images
PNGFlateDecodeLosslessYesScreenshots, graphics, text images
WebPConverted to JPEG/PNGVariesYes (lossy/lossless)Modern web images
GIFConverted (not recommended)LZWYesSimple graphics (limited support)

Page Size Reference

SizeDimensions (mm)Dimensions (inches)Dimensions (points)
A4 (default)210 x 2978.27 x 11.69595 x 842
Letter216 x 2798.5 x 11612 x 792
Legal216 x 3568.5 x 14612 x 1008
A3297 x 42011.69 x 16.54842 x 1190
Tabloid279 x 43211 x 17792 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

PDF File Size Considerations

PDF file size depends on image resolution, format, and compression:

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:

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.