How to create an uncompressed PDF file?

I can always convert the finished PDF with various utilities but that takes an extra step that would be comfortable to avoid.

31st May 2016
admin-marketing

During development testing, I'd prefer to create uncompressed, non-binary PDF files with iTextSharp so that I can check their internals easily. I can always convert the finished PDF with various utilities but that takes an extra step that would be comfortable to avoid. There are some places (e.g. PdfImage) where I can decide about compression level but I couldn't find anything about the compression used to output the individual PDF objects into the stream. Do you think this is possible with iTextSharp?

Posted on StackOverflow on May 15, 2014 by Gábor

In iText 7 you can set the compression level to 0, which means no compression using WriterProperties class:

WriterProperties properties = new WriterProperties()
        .setCompressionLevel(CompressionConstants.NO_COMPRESSION);
PdfWriter writer = new PdfWriter(dest, properties);
PdfDocument pdfDoc = new PdfDocument(writer);
Document doc = new Document(pdfDoc);
doc.add(new Paragraph("Hello World!"));
doc.close();

In this case your PDF syntax streams won't be compressed.

Click this link if you want to see how to answer this question in iText 5.



Contact

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now