Class PdfEncoder

  • All Implemented Interfaces:
    com.idrsolutions.image.Encoder

    public class PdfEncoder
    extends com.idrsolutions.image.JDeliImage
    implements com.idrsolutions.image.Encoder
    Class generates a PDF from a BufferedImage or Image file
    If the image is a multi-page TIFF then this class generates a multi-page PDF file

    Example 1 (writing from a BufferedImage):

    
     File pdfFile = new File("C:\\path\\to\\output\\file.pdf");
     pdfFile.createNewFile();
     PdfEncoder encoder = new PdfEncoder();
     encoder.write(bufferedImage, pdfFile);
     

    Example 2 (writing from a File):

    
     File pdfFile = new File("C:\\path\\to\\output\\file.pdf");
     pdfFile.createNewFile();
     PdfEncoder encoder = new PdfEncoder();
     encoder.write(new File("C:\\path\\to\\input\\image.PNG"), pdfFile); //can be BMP, JPEG, TIFF or any supported Image
     
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      PdfEncoderOptions getEncoderOptions()  
      void write​(java.awt.image.BufferedImage image, java.io.File pdfFile)
      Write a buffered image into a PDF file.
      void write​(java.awt.image.BufferedImage image, java.io.OutputStream bos)  
      void write​(java.io.File imageFile, java.io.File pdfFile)
      Writes an image file into a PDF file.
      • Methods inherited from class com.idrsolutions.image.JDeliImage

        optimiseImage
      • Methods inherited from class java.lang.Object

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

      • PdfEncoder

        public PdfEncoder()
    • Method Detail

      • write

        public void write​(java.awt.image.BufferedImage image,
                          java.io.File pdfFile)
                   throws java.io.IOException
        Write a buffered image into a PDF file.
        Parameters:
        image - buffered image to be converted
        pdfFile - output PDF file to write to
        Throws:
        java.io.IOException
      • write

        public void write​(java.io.File imageFile,
                          java.io.File pdfFile)
                   throws java.lang.Exception
        Writes an image file into a PDF file.

        If the file is a multi-page TIFF then this method writes a PDF with the same number of pages as the TIFF file contains.

        Parameters:
        imageFile - input image file to be converted
        pdfFile - output PDF file to write to
        Throws:
        java.io.IOException
        java.lang.Exception
      • write

        public void write​(java.awt.image.BufferedImage image,
                          java.io.OutputStream bos)
                   throws java.io.IOException
        Specified by:
        write in interface com.idrsolutions.image.Encoder
        Throws:
        java.io.IOException