Class AddImageToPDF

java.lang.Object
org.apache.pdfbox.examples.pdmodel.AddImageToPDF

public class AddImageToPDF extends Object
This is an example that creates a reads a document and adds an image to it.. The example is taken from the pdf file format specification.
  • Constructor Details

    • AddImageToPDF

      public AddImageToPDF()
  • Method Details

    • createPDFFromImage

      public void createPDFFromImage(String inputFile, String imagePath, String outputFile) throws IOException
      Add an image to an existing PDF document.
      Parameters:
      inputFile - The input PDF to add the image to.
      imagePath - The filename of the image to put in the PDF.
      outputFile - The file to write to the pdf to.
      Throws:
      IOException - If there is an error writing the data.
    • main

      public static void main(String[] args) throws IOException
      This will load a PDF document and add a single image on it.
      see usage() for commandline
      Parameters:
      args - Command line arguments.
      Throws:
      IOException
    • usage

      private void usage()
      This will print out a message telling how to use this example.