How do I embed G3/G4 compressed TIFF images in PDF?

Q: I am not sure how to efficiently embed TIFF images that are
compressed using CCITT Fax G4.

  • We used the method Image.Create(SDFDoc doc, byte[] image_data, int
    width, int height, int bpc, ColorSpace color_space, Image.InputFilter
    input_format). The imput image is CCITT gorup4 compressed and we set
    input filter to e_g4. But the output pdf file is blank.

  • Image.Create(SDFDoc doc, string filename, Obj encoder_hints) and
    and set the hints as
    ObjSet objset = new ObjSet();
    Obj tiff_hint = objset.CreateDict();
    tiff_hint.PutName(“ColorSpace”,“Gray”);
    tiff_hint.PutNumber(“BPC”, 1);
    tiff_hint.PutName(“Filter”,“CCITTFaxDecode”);
    But the output pdf has image compressed using FLATE.


A: Image.Create() method that accepts Image.InputFilter.e_g4 parameter
is used to ‘pass-through’ pre-compressed image data. Because you are
passing in raw (decompressed) image data - the output PDF generated
using this method will not be correct.

In order to embed and efficiently compress monochrome (1 BPP) raw
image data you should pass ‘JBIG2’ compression hint as follows:

// Use JBIG2 Encoding
ObjSet objset = new ObjSet();
Obj jbig2_hint = objset.CreateName(“JBIG2”); …
Image img = Image.Create(doc, bmp, jbig2_hint);

For a full sample code listing, please take a look at AddImage sample
project (http://www.pdftron.com/net/samplecode.html#AddImage).

For another example, please take a look at:
http://groups.google.com/group/pdfnet-sdk/browse_thread/thread/3f5907b888be37cd/124d017859f32391