Class JPEGFactory


  • public final class JPEGFactory
    extends Object
    Factory for creating a PDImageXObject containing a JPEG compressed image.
    • Method Detail

      • createFromStream

        public static PDImageXObject createFromStream​(PDDocument document,
                                                      InputStream stream)
                                               throws IOException
        Creates a new JPEG Image XObject from an input stream containing JPEG data. The input stream data will be preserved and embedded in the PDF file without modification.
        Parameters:
        document - the document where the image will be created
        stream - a stream of JPEG data
        Returns:
        a new Image XObject
        Throws:
        IOException - if the input stream cannot be read
      • createFromImage

        public static PDImageXObject createFromImage​(PDDocument document,
                                                     android.graphics.Bitmap image)
                                              throws IOException
        Creates a new JPEG Image XObject from a Buffered Image.
        Parameters:
        document - the document where the image will be created
        image - the buffered image to embed
        Returns:
        a new Image XObject
        Throws:
        IOException - if the JPEG data cannot be written
      • createFromImage

        public static PDImageXObject createFromImage​(PDDocument document,
                                                     android.graphics.Bitmap image,
                                                     float quality)
                                              throws IOException
        Creates a new JPEG Image XObject from a Buffered Image and a given quality. The image will be created at 72 DPI.
        Parameters:
        document - the document where the image will be created
        image - the buffered image to embed
        quality - the desired JPEG compression quality
        Returns:
        a new Image XObject
        Throws:
        IOException - if the JPEG data cannot be written
      • createFromImage

        public static PDImageXObject createFromImage​(PDDocument document,
                                                     android.graphics.Bitmap image,
                                                     float quality,
                                                     int dpi)
                                              throws IOException
        Creates a new JPEG Image XObject from a Buffered Image, a given quality and DPI.
        Parameters:
        document - the document where the image will be created
        image - the buffered image to embed
        quality - the desired JPEG compression quality
        dpi - the desired DPI (resolution) of the JPEG
        Returns:
        a new Image XObject
        Throws:
        IOException - if the JPEG data cannot be written