Just dropping this here because I spent DAYS try to figure out how to get PDF to read a zlib from Intersystems.

You'll see code above to use $e(string,4,*-5) to make it "deflate" but PDF wants ZLIB.

The issue turned out to be that Intersystems adds a first # character and a last character around the zlib compression.

If you do this:

S pdfcompress=$E($System.Util.Compress(instring,"zlib"),2,*-1) ; remove first and last character

THEN the pdf reader properly reads and processes that in the stream object (when using /FlateDecode)

Wasted days just because of 2 added characters.  Hope this helps someone else.

Just dropping this here because I spent DAYS try to figure out how to get PDF to read a zlib from Intersystems.

You'll see code above to use $e(string,4,*-5) to make it "deflate" but PDF wants ZLIB.

The issue turned out to be that Intersystems adds a first # character and a last character around the zlib compression.

If you do this:

S pdfcompress=$E($System.Util.Compress(instring,"zlib"),2,*-1) ; remove first and last character

THEN the pdf reader properly reads and processes that in the stream object (when using /FlateDecode)

Wasted days just because of 2 added characters.  Hope this helps someone else.