How to turn off Flate compression and how to remove compression from existing PDFs?

Q: Is it possible to turn of Flate compression for all or part of a
drawing? We want to be able to do a clear text search on strings in the
PDF file, but can't do that if the strings are compressed.

Yes, using PDFNet it is possible to decompress all Flate streams (or
any other compressed streams) in the new or any existing document. This
can be implemented along the lines of JBIG2 sample project

Of course instead of processing only Image streams you can process any
Flate stream. For example:

Doc* cos_doc = pdf_doc.GetSDFDoc();
int num_objs = cos_doc->XRefSize();
for(int i=1; i<num_objs; ++i) {
  Obj* obj = cos_doc->GetObj(i);
  if(obj && !obj->IsFree() && obj->IsStream()) {
      // You could check here is the Filter is Flate.
      // If not you could skip to another object (see jbig sample

  AutoPtr<Filter> filter(obj->GetDecodedStream());
      FilterReader reader(*filter);
      Obj* decstm = cos_doc->CreateIndirectStream(reader);

      // Copy all dictionary entries from obj to decstm

      cos_doc->Swap(i, decstm ->GetObjNum());
pdf_doc.Save("decompressed.pdf", Doc::SaveOptions::e_remove_unused, 0);

In case you are only creating new PDF content, you can specify 'false'
as a third parameter to ElementWriter.Begin(...) method (e.g.
writer.Begin(page, false, true)).

The description of this flag is as follows:

param compress: An optional flag indicating whether the page content
stream should be compressed. This may be useful for debugging content
streams. Also some applications need to do a clear text search on
strings in the PDF files. By default, all content streams are

This option is available starting in PDFNet v.3.6 and above.