org.apache.pdfbox.pdmodel.graphics.image

## Class CCITTFactory

- java.lang.Object
- - org.apache.pdfbox.pdmodel.graphics.image.CCITTFactory

    public final class CCITTFactory
    extends Object

Factory for creating a PDImageXObject containing a CCITT Fax compressed TIFF image.

Author:
  Ben Litchfield, Paul King

### Method Summary

All Methods Static Methods Concrete Methods
`static PDImageXObject` `createFromByteArray(PDDocument document, byte[] byteArray)` Creates a new CCITT Fax compressed image XObject from a specific image of a TIFF file stored in a byte array.
`static PDImageXObject` `createFromByteArray(PDDocument document, byte[] byteArray, int number)` Creates a new CCITT Fax compressed image XObject from a specific image of a TIFF file stored in a byte array.
`static PDImageXObject` `createFromFile(PDDocument document, File file)` Creates a new CCITT Fax compressed image XObject from the first image of a TIFF file.
`static PDImageXObject` `createFromFile(PDDocument document, File file, int number)` Creates a new CCITT Fax compressed image XObject from a specific image of a TIFF file.
`static PDImageXObject` `createFromImage(PDDocument document, BufferedImage image)` Creates a new CCITT group 4 (T6) compressed image XObject from a b/w BufferedImage.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### createFromImage

    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` - the document to create the image as part of.
  `image` - the image.
Returns:
  a new image XObject.
Throws:
  `IOException` - if there is an error creating the image.
  `IllegalArgumentException` - if the BufferedImage is not a b/w image.

#### createFromByteArray

    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 `createFromImage(PDDocument, BufferedImage)` instead.

Parameters:
  `document` - the document to create the image as part of.
  `byteArray` - the TIFF file in a byte array which contains a suitable CCITT compressed image
Returns:
  a new Image XObject
Throws:
  `IOException` - if there is an error reading the TIFF data.

#### createFromByteArray

    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 `createFromImage(PDDocument, BufferedImage)` instead.

Parameters:
  `document` - the document to create the image as part of.
  `byteArray` - the TIFF file in a byte array which contains a suitable CCITT compressed image
  `number` - TIFF image number, starting from 0
Returns:
  a new Image XObject
Throws:
  `IOException` - if there is an error reading the TIFF data.

#### createFromFile

    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 `createFromImage(PDDocument, BufferedImage)` instead.

Parameters:
  `document` - the document to create the image as part of.
  `file` - the TIFF file which contains a suitable CCITT compressed image
Returns:
  a new Image XObject
Throws:
  `IOException` - if there is an error reading the TIFF data.

#### createFromFile

    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 `createFromImage(PDDocument, BufferedImage)` instead.

Parameters:
  `document` - the document to create the image as part of.
  `file` - the TIFF file which contains a suitable CCITT compressed image
  `number` - TIFF image number, starting from 0
Returns:
  a new Image XObject
Throws:
  `IOException` - if there is an error reading the TIFF data.