code: public void setData(byte[] data, boolean compress, int compressionLevel) {
          remove(PdfName.FILTER);
          this.offset = -1;
          if (Document.compress && compress) {
              try {
                  ByteArrayOutputStream stream = new ByteArrayOutputStream();
                  Deflater deflater = new Deflater(compressionLevel);
                  DeflaterOutputStream zip = new DeflaterOutputStream(stream, deflater);
                  zip.write(data);
                  zip.close();
                  deflater.end();
                  bytes = stream.toByteArray();
                  this.compressionLevel = compressionLevel;
              }
              catch (IOException ioe) {
                  throw new ExceptionConverter(ioe);
              }
              put(PdfName.FILTER, PdfName.FLATEDECODE);
          }
          else
              bytes = data;
          setLength(bytes.length);
      }
docs: Sets the data associated with the stream, either compressed or
  uncompressed. Note that the data will never be compressed if
  Document.compress is set to false.
  
  @param data raw data, decrypted and uncompressed.
  @param compress true if you want the stream to be compressed.
  @param compressionLevel	a value between -1 and 9 (ignored if compress == false)
  @since	iText 2.1.3