public final class JPEGFactory
extends java.lang.Object
Modifier and Type | Method | Description |
---|---|---|
static PDImageXObject |
createFromByteArray(PDDocument document,
byte[] byteArray) |
Creates a new JPEG Image XObject from a byte array containing JPEG data.
|
static PDImageXObject |
createFromImage(PDDocument document,
java.awt.image.BufferedImage image) |
Creates a new JPEG PDImageXObject from a BufferedImage.
|
static PDImageXObject |
createFromImage(PDDocument document,
java.awt.image.BufferedImage image,
float quality) |
Creates a new JPEG PDImageXObject from a BufferedImage and a given quality.
|
static PDImageXObject |
createFromImage(PDDocument document,
java.awt.image.BufferedImage image,
float quality,
int dpi) |
Creates a new JPEG Image XObject from a BufferedImage, a given quality and dpi metadata.
|
static PDImageXObject |
createFromStream(PDDocument document,
java.io.InputStream stream) |
Creates a new JPEG Image XObject from an input stream containing JPEG data.
|
public static PDImageXObject createFromStream(PDDocument document, java.io.InputStream stream) throws java.io.IOException
document
- the document where the image will be createdstream
- a stream of JPEG datajava.io.IOException
- if the input stream cannot be readpublic static PDImageXObject createFromByteArray(PDDocument document, byte[] byteArray) throws java.io.IOException
document
- the document where the image will be createdbyteArray
- bytes of JPEG imagejava.io.IOException
- if the input stream cannot be readpublic static PDImageXObject createFromImage(PDDocument document, java.awt.image.BufferedImage image) throws java.io.IOException
Do not read a JPEG image from a stream/file and call this method; you'll get more speed and
quality by calling createFromStream()
instead.
document
- the document where the image will be createdimage
- the BufferedImage to embedjava.io.IOException
- if the JPEG data cannot be writtenpublic static PDImageXObject createFromImage(PDDocument document, java.awt.image.BufferedImage image, float quality) throws java.io.IOException
Do not read a JPEG image from a stream/file and call this method; you'll get more speed and
quality by calling createFromStream()
instead.
The image will be created with a dpi value of 72 to be stored in metadata.
document
- the document where the image will be createdimage
- the BufferedImage to embedquality
- The desired JPEG compression quality; between 0 (best
compression) and 1 (best image quality). See
ImageWriteParam.setCompressionQuality(float)
for more details.java.io.IOException
- if the JPEG data cannot be writtenpublic static PDImageXObject createFromImage(PDDocument document, java.awt.image.BufferedImage image, float quality, int dpi) throws java.io.IOException
Do not read a JPEG image from a stream/file and call this method; you'll get more speed and
quality by calling createFromStream()
instead.
document
- the document where the image will be createdimage
- the BufferedImage to embedquality
- The desired JPEG compression quality; between 0 (best
compression) and 1 (best image quality). See
ImageWriteParam.setCompressionQuality(float)
for more details.dpi
- the desired dpi (resolution) value of the JPEG to be stored in metadata. This
value has no influence on image content or size.java.io.IOException
- if the JPEG data cannot be writtenCopyright © 2002–2018. All rights reserved.