title: Java - Merge multiple images to a single PDF using PDFBox
body: <p>I was able to merge multiple PDF files into a single PDF using the code below -</p>
  
  <pre><code>public void mergePDF() {
          File file1 = new File("inputPDF/001.pdf");
          File file2 = new File("inputPDF/002.pdf");
          File file3 = new File("inputPDF/003.pdf");
          File file4 = new File("inputPDF/004.pdf");
          try {
              PDDocument doc1 = PDDocument.load(file1);
              PDDocument doc2 = PDDocument.load(file2);
              PDDocument doc3 = PDDocument.load(file3);
              PDDocument doc4 = PDDocument.load(file4);
              PDFMergerUtility PDFmerger = new PDFMergerUtility(); 
              PDFmerger.setDestinationFileName("outputImages/merged.pdf");
              System.out.println("Destination path set to "+PDFmerger.getDestinationFileName());
              PDFmerger.addSource(file1);
              PDFmerger.addSource(file2);
              PDFmerger.addSource(file3);
              PDFmerger.addSource(file4);     
              //Merging the documents
              PDFmerger.mergeDocuments();
              doc1.close();
              doc2.close();
              doc3.close();
              doc4.close();
              System.out.println("Done!");            
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>However, my requirement is to merge multiple images (JPG, PNG) to a single PDF as well.</p>
  
  <p>Is it possible to merge multiple images to a single PDF using PDFBox?</p>