Brotli is coming to PDF

Brotli is coming to PDF

A PDF file is, at heart, a container for data, much of which is stored as streams: fonts, image, page content, attached files and so on. In a typical PDF the vast majority of the file will be streams, and those streams are compressed with one of a number of algorithms to reduce the size of the file.

For general compression the go-to algorithm is Flate, the same algorithm used in the Zip file format, PNG images and so on. It's still effective but was added to the PDF format in 1996 - thirty years ago, at the time of writing. That's a long time in technology.

To improve on this the PDF association have been investigating alternatives, and have recently formalized the addition of the Brotli compression format to the PDF format. Developed initially by Google, Brotli compression is used in the WOFF font format used on the web so is widely supported on many platforms - and as a general compression format it's a drop-in replacement for Flate.

How effective is it? In testing we're seeing text-heavy PDF files compressed with Brotli are roughly 85% of the size of the same file compressed with Flate.

Chicken and Egg

The downside is that adding Brotli compression is a breaking change: if you use Brotli compression to write the file, only PDF tools that support Brotli will be able to read it. The PDF industry as a whole will have to transition to add support, and it's for that reason that we're publishing this article outlining the level of support for Brotli in BFO tools

BFO and Brotli

Although we haven't officially announced it until now, BFO tools have supported Brotli for some time.

  • The BFO PDF Library has been shipping with support for reading PDFs compressd with Brotli since release 2.29.3, released September 2025. No additional Jars are required: a 100% Java Brotli decoder (derived from the Google Java Brotli decoder) is baked into the bfopdf.jar.
  • The BFO PDF Library has been shipping with support for writing PDFs compressd with Brotli since release 2.29.5, released April 2026. The current implementation builds on the com.aayushatharva.brotli4j package, which uses native bindings and must be installed separately: build instructions are available on that site, or just download brotli-1.20-fat.jar and add it to your classpath; this includes native bindings for most platforms.

To create a PDF compressed with Brotli, change the PDF constructor as shown:

    // PDF internals will be compressed with Flate
    PDF pdf = new PDF();

    // PDF internals will be compressed with Brotli
    OutputProfile profile = new OutputProfile(OutputProfile.Default);
    profile.setRequired(OutputProfile.Feature.FilterBrotli);
    PDF pdf = new PDF(profile);
   

Our other products (BFO Report Generator and BFO Publisher) will be upgraded soon to add Brotli support.

Summary

These are very early days for Brotli and PDF. Our API is functional and we've already done interoperability testing with several other firms (BFO have been part of the industry push for Brotli), so it's ready to use now. We look forward to seeing how it will be adopted by industry.