Images To PDF

Developers can use IronPDF to combine multiple images into a single PDF document.

The PdfDocument.fromImage method accepts a list of Path objects, each of which references a valid path to an image stored on a local file system. This gives the developer a lot of freedom in specificity. The developer can build this list to include groups of images spanning multiple directories, to include images matching specific naming or typing criteria, etc. If the images are sourced from the same directory (as is the case in the example below), the developer can simply utilize a DirectoryStream among other java.nio.file classes to quickly build up a list of all the images contained in the directory.

PdfDocument.fromImage will render each image referenced in the list on a separate page in the PDF document.

If the images need to be placed in separate PDF documents (and not combined into one), then developers can do either of the following:

  1. Iteratively call PdfDocument.fromImage using lists containing only one Path object.
  2. Combine all images into one PDF document as shown in the example above, and then copy each page into new PDF documents with the PdfDocument.copyPage method.

Explore our Java PDF to Image Tutorial for more insights on transforming PDFs effortlessly!

Talk to an Expert Five Star Trust Score Rating

Ready to Get Started?