How do I embed image in PDF using lossless PNG (Flate) compression?

Q:

I would like to embed images to my PDFs without loosing any quality (i.e. using PNG instead of JPEG compression).

I was able to achieve lossless embedding with RAW/uncompressed format but the file size is huge.

I am trying to understand what is being done “under the hood” by PDFTron when adding images to the PDF that result in the pixilation effect.

How do I embed image in PDF using lossless PNG (Flate) compression?

A:

To embed image in PDF with Flate you need to specify the compression hint as follows:

Obj flate_hint = objset.CreateArray();

flate_hint.PushBackName(“Flate”);

flate_hint.PushBackName(“Level”);

flate_hint.PushBackNumber(9); // Set max compression vs speed.

For more info, please see:

https://groups.google.com/d/topic/pdfnet-sdk/wCK-rAmEPr0/discussion