Skip to main content
Skip table of contents

How to create an uncompressed PDF file?

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.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.