Images To PDF
from ironpdf import *

# One or more images as a list. This example selects all JPEG images in a specific 'assets' folder.
image_files = [os.path.join("assets", f) for f in os.listdir("assets") if f.lower().endswith(('.jpg', '.jpeg'))]

directory_list = List[str]()
for i in range(len(image_files)):
    directory_list.Add(image_files[i])

# Converts the images to a PDF and save it.
ImageToPdfConverter.ImageToPdf(directory_list).SaveAs("composite.pdf")

# Also see PdfDocument.RasterizeToImageFiles() method to flatten a PDF to images or thumbnails
pip install ironpdf
Images To PDF

Images To PDF

The ImageToPdfConverter class creates PDF documents from images.

Call the ImageToPdfConverter.ImageToPdf function using a valid file path to an image to produce a new PDF document from that image.

Calling ImageToPdfConverter.ImageToPdf using a list of image paths will produce a single PDF document containing each image on separate pages.

  • Import necessary modules: FPDF for creating PDF files, Image from PIL for processing images, and os for file operations.
  • The method image_to_pdf takes one or multiple image paths and converts them into a PDF file, saving it at the specified output path.
  • Images are converted to RGB to ensure compatibility.
  • Temporary files are used to maintain the consistency of image formats.
  • The method handles single image paths and lists of image paths seamlessly.
Learn how to convert PDFs to images with IronPDF
View on GitHub

Ready to Get Started?

Version:2026.11just released