Class AddImageToPDF


  • public class AddImageToPDF
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      AddImageToPDF()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void createPDFFromImage​(java.lang.String inputFile, java.lang.String imagePath, java.lang.String outputFile)
      Add an image to an existing PDF document.
      static void main​(java.lang.String[] args)
      This will load a PDF document and add a single image on it.
      private void usage()
      This will print out a message telling how to use this example.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AddImageToPDF

        public AddImageToPDF()
    • Method Detail

      • createPDFFromImage

        public void createPDFFromImage​(java.lang.String inputFile,
                                       java.lang.String imagePath,
                                       java.lang.String outputFile)
                                throws java.io.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:
        java.io.IOException - If there is an error writing the data.
      • main

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

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