Two Servlet Filters Every Web Application Should Have
Subject:   Compressing PDF output
Date:   2004-01-23 03:06:20
From:   ankleon
I have servlet which runs a web service for another J2EE application. The servlet returns a PDF document after transforming a XML using a XSL document received by it through HttpURLConnection that is established. Is it feasible for me to send this response through a Compression Filter?Plz advice.

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • Compressing PDF output
    2004-01-25 20:44:15  jfalkner [View]

    Yes, you certainly can send PDF through a compression filter. However, I am unsure if PDF is compressed already, in which case you would likely be wasting server power compressing it again.

    Is anyone a PDF expert, is it beneficial to ZIP compress a PDF document?
    • Compressing PDF output
      2008-11-08 22:59:37  corlettk [View]

      As you suspect, PDF is "pretty solid" already.

      In fact PDFs main difference with its precursor, PostScript, is its lightweight data structure (less wasted space) and the internal use of several compression algorithms including RLE & LZW... so GZipping most PDF's doesn't reduce there size very much at all.

      BUT... PFDs are by nature "static content", so if you combine compression with response caching (especially of very large documents) you could be onto a winner... On the downside, I suspect some browsers won't recognise compressed-PDF, they'll see Content-Encoding "application/pdf" and ignore the additional "gzip". Life's a gamble ;-)

      More here:

      Cheers. Keith.