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.PutNumber(“BPC”, 1);
    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 (

For another example, please take a look at: