Commit 25e96b6d authored by Adrian Johnson's avatar Adrian Johnson

pdfimages: support ccitt output

parent 08641326
......@@ -797,6 +797,11 @@ public:
virtual void unfilteredReset ();
int getEncoding() { return encoding; }
GBool getEndOfLine() { return endOfLine; }
int getColumns() { return columns; }
GBool getBlackIs1() { return black; }
void ccittReset(GBool unfiltered);
......@@ -454,6 +454,41 @@ void ImageOutputDev::writeImage(GfxState *state, Object *ref, Stream *str,
// dump JBIG2 embedded file
writeRawImage(str, "jb2e");
} else if (dumpCCITT && str->getKind() == strCCITTFax && !inlineImg) {
// write CCITT parameters
CCITTFaxStream *ccittStr = static_cast<CCITTFaxStream *>(str);
FILE *f;
if (!(f = fopen(fileName, "wb"))) {
error(errIO, -1, "Couldn't open image file '{0:s}'", fileName);
if (ccittStr->getEncoding() < 0)
fprintf(f, "-4 ");
else if (ccittStr->getEncoding() == 0)
fprintf(f, "-1 ");
fprintf(f, "-2 ");
if (ccittStr->getEndOfLine())
fprintf(f, "-A ");
fprintf(f, "-P ");
fprintf(f, "-X %d ", ccittStr->getColumns());
if (ccittStr->getBlackIs1())
fprintf(f, "-W ");
fprintf(f, "-B ");
fprintf(f, "-M\n"); // PDF uses MSB first
// dump CCITT file
writeRawImage(str, "ccitt");
} else if (outputPNG) {
// output in PNG format
......@@ -85,6 +85,9 @@ public:
// Use JBIG2 format for JBIG2 files
void enableJBig2(GBool jbig2) { dumpJBIG2 = jbig2; }
// Use CCITT format for CCITT files
void enableCCITT(GBool ccitt) { dumpCCITT = ccitt; }
// Check if file was successfully created.
virtual GBool isOk() { return ok; }
......@@ -162,6 +165,7 @@ private:
GBool dumpJPEG; // set to dump native JPEG files
GBool dumpJP2; // set to dump native JPEG2000 files
GBool dumpJBIG2; // set to dump native JBIG2 files
GBool dumpCCITT; // set to dump native CCITT files
GBool outputPNG; // set to output in PNG format
GBool outputTiff; // set to output in TIFF format
GBool pageNames; // set to include page number in file names
......@@ -50,12 +50,49 @@ Write images in JPEG2000 format as JP2 files instead of the default format. The
.B \-jbig2
Write images in JBIG2 format as JBIG2 files instead of the default format. JBIG2 data in PDF is of the embedded type. The embedded type of JBIG2 has an optional separate file containing global data. The embedded data is written with the extension .jb2e and the global data (if available) will be written to the same image number with the extension .jb2g. The content of both these files is indentical to the JBIG2 data in the PDF.
.B \-ccitt
Write images in CCITT format as CCITT files instead of the default
format. The CCITT file is identical to the JPEG2000 data stored in the
PDF. PDF files contain additional parameters specifying
how to decode the CCITT data. These parameters are translated to
fax2tiff input options and written to a .params file with the same image
number. The parameters are:
.B \-1
1D Group 3 encoding
.B \-2
2D Group 3 encoding
.B \-4
Group 4 encoding
.B \-A
Beginning of line is aligned on a byte boundary
.B \-P
Beginning of line is not aligned on a byte boundary
.B \-X n
The image width in pixels
.B \-W
Encoding uses 1 for black and 0 for white
.B \-B
Encoding uses 0 for black and 1 for white
.B \-M
Input data fills from most significant bit to least significant bit.
.B \-list
Instead of writing the images, list the images along with various information for each image. Do not specify an
.IR image-root
with this option.
The following information is listed for each font:
The following information is listed for each image:
.B page
......@@ -55,6 +55,7 @@ static GBool enableTiff = gFalse;
static GBool dumpJPEG = gFalse;
static GBool dumpJP2 = gFalse;
static GBool dumpJBIG2 = gFalse;
static GBool dumpCCITT = gFalse;
static GBool pageNames = gFalse;
static char ownerPassword[33] = "\001";
static char userPassword[33] = "\001";
......@@ -81,6 +82,8 @@ static const ArgDesc argDesc[] = {
"write JPEG2000 images as JP2 files"},
{"-jbig2", argFlag, &dumpJBIG2, 0,
"write JBIG2 images as JBIG2 files"},
{"-ccitt", argFlag, &dumpCCITT, 0,
"write CCITT images as CCITT files"},
{"-list", argFlag, &listImages, 0,
"print list of images instead of saving"},
{"-opw", argString, ownerPassword, sizeof(ownerPassword),
......@@ -191,6 +194,7 @@ int main(int argc, char *argv[]) {
doc->displayPages(imgOut, firstPage, lastPage, 72, 72, 0,
gTrue, gFalse, gFalse);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment