Top Description Constructors Methods
org.apache.pdfbox.pdmodel.graphics.image

public final Class CCITTFactory

extends Object
Class Inheritance
Imports
java.awt.image.BufferedImage, java.io.ByteArrayInputStream, .ByteArrayOutputStream, .File, .IOException, .OutputStream, javax.imageio.stream.MemoryCacheImageOutputStream, org.apache.pdfbox.cos.COSDictionary, .COSName, org.apache.pdfbox.filter.Filter, .FilterFactory, org.apache.pdfbox.io.RandomAccessReadBuffer, .RandomAccessReadBufferedFile, .RandomAccessRead, org.apache.pdfbox.pdmodel.PDDocument, org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace, .PDDeviceGray

Factory for creating a PDImageXObject containing a CCITT Fax compressed TIFF image.
Authors
Ben Litchfield, Paul King

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static PDImageXObject

Returns:

a new Image XObject
createFromByteArray
(PDDocument
the document to create the image as part of.
document
,
byte[]
the TIFF file in a byte array which contains a suitable CCITT compressed image
byteArray
)

Creates a new CCITT Fax compressed image XObject from a specific image of a TIFF file stored in a byte array.

public static PDImageXObject

Returns:

a new Image XObject
createFromByteArray
(PDDocument
the document to create the image as part of.
document
,
byte[]
the TIFF file in a byte array which contains a suitable CCITT compressed image
byteArray
,
int
TIFF image number, starting from 0
number
)

Creates a new CCITT Fax compressed image XObject from a specific image of a TIFF file stored in a byte array.

public static PDImageXObject

Returns:

a new Image XObject
createFromFile
(PDDocument
the document to create the image as part of.
document
,
File
the TIFF file which contains a suitable CCITT compressed image
file
)

Creates a new CCITT Fax compressed image XObject from the first image of a TIFF file.

public static PDImageXObject

Returns:

a new Image XObject
createFromFile
(PDDocument
the document to create the image as part of.
document
,
File
the TIFF file which contains a suitable CCITT compressed image
file
,
int
TIFF image number, starting from 0
number
)

Creates a new CCITT Fax compressed image XObject from a specific image of a TIFF file.

public static PDImageXObject

Returns:

a new image XObject.
createFromImage
(PDDocument
the document to create the image as part of.
document
,
BufferedImage
the image.
image
)

Creates a new CCITT group 4 (T6) compressed image XObject from a b/w BufferedImage.

private static PDImageXObject

Returns:

a new Image XObject, or null if no such page
createFromRandomAccessImpl
(PDDocument
the document to create the image as part of.
document
,
RandomAccessRead
the random access TIFF file which contains a suitable CCITT compressed image
reader
,
int
TIFF image number, starting from 0
number
)

Creates a new CCITT Fax compressed image XObject from a TIFF file.

private static void
private static PDImageXObject
prepareImageXObject(PDDocument document, byte[] byteArray, int width, int height, PDColorSpace initColorSpace)

private static int
readlong(char endianess, RandomAccessRead raf)

private static int
readshort(char endianess, RandomAccessRead raf)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CCITTFactoryback to summary
private CCITTFactory()

Method Detail

createFromByteArrayback to summary
public static PDImageXObject createFromByteArray(PDDocument document, byte[] byteArray) throws IOException

Creates a new CCITT Fax compressed image XObject from a specific image of a TIFF file stored in a byte array. Only single-strip CCITT T4 or T6 compressed TIFF files are supported. If you're not sure what TIFF files you have, use LosslessFactory#createFromImage(PDDocument, BufferedImage) or CCITTFactory#createFromImage(PDDocument, BufferedImage) instead.

Parameters
document:PDDocument

the document to create the image as part of.

byteArray:byte[]

the TIFF file in a byte array which contains a suitable CCITT compressed image

Returns:PDImageXObject

a new Image XObject

Exceptions
IOException:
if there is an error reading the TIFF data.
createFromByteArrayback to summary
public static PDImageXObject createFromByteArray(PDDocument document, byte[] byteArray, int number) throws IOException

Creates a new CCITT Fax compressed image XObject from a specific image of a TIFF file stored in a byte array. Only single-strip CCITT T4 or T6 compressed TIFF files are supported. If you're not sure what TIFF files you have, use LosslessFactory#createFromImage(PDDocument, BufferedImage) or CCITTFactory#createFromImage(PDDocument, BufferedImage) instead.

Parameters
document:PDDocument

the document to create the image as part of.

byteArray:byte[]

the TIFF file in a byte array which contains a suitable CCITT compressed image

number:int

TIFF image number, starting from 0

Returns:PDImageXObject

a new Image XObject

Exceptions
IOException:
if there is an error reading the TIFF data.
createFromFileback to summary
public static PDImageXObject createFromFile(PDDocument document, File file) throws IOException

Creates a new CCITT Fax compressed image XObject from the first image of a TIFF file. Only single-strip CCITT T4 or T6 compressed TIFF files are supported. If you're not sure what TIFF files you have, use LosslessFactory#createFromImage(org.apache.pdfbox.pdmodel.PDDocument, java.awt.image.BufferedImage) or CCITTFactory#createFromImage(PDDocument, BufferedImage) instead.

Parameters
document:PDDocument

the document to create the image as part of.

file:File

the TIFF file which contains a suitable CCITT compressed image

Returns:PDImageXObject

a new Image XObject

Exceptions
IOException:
if there is an error reading the TIFF data.
createFromFileback to summary
public static PDImageXObject createFromFile(PDDocument document, File file, int number) throws IOException

Creates a new CCITT Fax compressed image XObject from a specific image of a TIFF file. Only single-strip CCITT T4 or T6 compressed TIFF files are supported. If you're not sure what TIFF files you have, use LosslessFactory#createFromImage(PDDocument, BufferedImage) or CCITTFactory#createFromImage(PDDocument, BufferedImage) instead.

Parameters
document:PDDocument

the document to create the image as part of.

file:File

the TIFF file which contains a suitable CCITT compressed image

number:int

TIFF image number, starting from 0

Returns:PDImageXObject

a new Image XObject

Exceptions
IOException:
if there is an error reading the TIFF data.
createFromImageback to summary
public static PDImageXObject createFromImage(PDDocument document, BufferedImage image) throws IOException

Creates a new CCITT group 4 (T6) compressed image XObject from a b/w BufferedImage. This compression technique usually results in smaller images than those produced by LosslessFactory#createFromImage(PDDocument, BufferedImage).

Parameters
document:PDDocument

the document to create the image as part of.

image:BufferedImage

the image.

Returns:PDImageXObject

a new image XObject.

Exceptions
IOException:
if there is an error creating the image.
IllegalArgumentException:
if the BufferedImage is not a b/w image.
createFromRandomAccessImplback to summary
private static PDImageXObject createFromRandomAccessImpl(PDDocument document, RandomAccessRead reader, int number) throws IOException

Creates a new CCITT Fax compressed image XObject from a TIFF file.

Parameters
document:PDDocument

the document to create the image as part of.

reader:RandomAccessRead

the random access TIFF file which contains a suitable CCITT compressed image

number:int

TIFF image number, starting from 0

Returns:PDImageXObject

a new Image XObject, or null if no such page

Exceptions
IOException:
if there is an error reading the TIFF data.
extractFromTiffback to summary
private static void extractFromTiff(RandomAccessRead reader, OutputStream os, COSDictionary params, int number) throws IOException
prepareImageXObjectback to summary
private static PDImageXObject prepareImageXObject(PDDocument document, byte[] byteArray, int width, int height, PDColorSpace initColorSpace) throws IOException
readlongback to summary
private static int readlong(char endianess, RandomAccessRead raf) throws IOException
readshortback to summary
private static int readshort(char endianess, RandomAccessRead raf) throws IOException