Assuming you are using 1.8.8, put the ccitt stream into a PDStream object, then call the PDCcitt constructor with that PDStream.

PDStream pd = new PDStream(doc, new ByteArrayInputStream(data), true);

       COSStream dic = pd.getCOSStream();

       COSDictionary decodeParms = new COSDictionary();
       decodeParms .setInt(COSName.COLUMNS,  nnnnn);
       decodeParms .setInt(COSName.ROWS,  nnnnn);
decodeParms .setBoolean(COSName.BLACK_IS_1, ?????); // test which is right, true or false
       decodeParms .setInt(COSName.K, -1);   // -1 for G4

        dic.setItem(COSName.FILTER, COSName.CCITTFAX_DECODE);
        dic.setItem(COSName.SUBTYPE, COSName.IMAGE);
        dic.setItem(COSName.TYPE, COSName.XOBJECT);
        dic.setItem(COSName.DECODE_PARMS, decodeParms);

        setBitsPerComponent(1);
        setColorSpace(new PDDeviceGray());
        setWidth(decodeParms.getInt(COSName.COLUMNS));
        setHeight(decodeParms.getInt(COSName.ROWS));


Now if that has worked, you can create the PDCCitt object from the PDStream object. That one you handle like in the ImageToPDF example. (Download the 1.8 source code)

If it doesn't work, email me (tilman at snafu dot de ) a non-confidential file with that raw G4 data and the col / row values and I'll fix any errors I may have inserted here. (tonight, after work)

Tilman

Am 19.02.2015 um 05:46 schrieb John Lussmyer:
So, I have a block of data (byte[]) that represents a scanned image, compressed 
using CCITTG4.
I'm new to PDFBox. (of course)

So far, I haven't been able to figure out how I can create a page that consists 
of just that image.
All the examples want to read the image from a file, and decompress it.
Since I already have it as a compressed block, I'd prefer to just use it as-is.
The last time I did much work with PDF's, I was working directly with the 
dictionaries.  I don't see a simple way of even getting to the Page dictionary 
in PDFbox.

Anyone have a suggestion on how to do this?

--
Worlds only All Electric F-250 truck! 
http://john.casadelgato.com/Electric-Vehicles/1995-Ford-F-250



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to