As part of the rewrite of our Java CCITT Decoder, I have spent a lot of time with the format. It is quite a complicated topic so I thought some articles would be helpful.
There are actually several types of CCITT. When decoding CCITT encoded PDF files there are three different types of CCITT formats that could be encountered. This is usually differentiated by the K-value in the PDF file. The K-value by default is set to 0 however; it could be greater or less than zero depending on the CCITT format used in encoding the PDF file.
Have a look at this example from a PDF file created with OpenOffice which has a K-value of -1. Notice also that we ignore Rows because it has a value of zero (obviously not possible).
The main types of CCITT format used in encoding PDFs include:
- Group 3 One-Dimensional (G31D): usually have a K-value of 0.
- Group 3 Two-Dimensional (G32D): usually have a K-values greater than 0.
- Group 4 Two-Dimensional (G42D): usually have K-values less than 0.
All these formats have their advantages and work differently in how the data in the PDF stream is decoded. The names of the formats are quite self explanatory in the way that they work except for the G42D which works in a more interesting manner. This would be covered in future articles. Stay tuned!
Would you like to know more about PDF files?
This post is part of our “Understanding the PDF File Format” series. In each article, we discuss a PDF feature, bug, gotcha or tip. If you wish to learn more about PDF, we have 20 years worth of PDF knowledge and tips, so click here to visit our series index!
Do you need to read or write Tiff files in Java?
Our JDeli image library offers a range of advantages over ImageIO and alternatives for Tiff files, including:
- prevents heap related JVM crashes
- reads 1-32 bit bilevel, grayscale, rgb, argb, cmyk, acmyk, ycbcr Colorspaces, and converts to sRGB BufferedImage
- implements both Little and Big Endian Byte Ordering
- decompresses uncompressed, CCITT group 3 and 4, Deflate/Adobe Deflate, LZW, Packbits
- support for Single, Multi-file, Tiling, Planar (Chunky, Separated), Predictor, 16,32 bit floating samples
- improve read performance
- supports threading
- superior image scaling algorithms