PDF Compression - HTML to PDF (wkhtmltopdf)
<h2>Background</h2>

<p>I'm working on a Scala/Java project where we convert individual <strong>HTML files to PDF files.</strong> We then merge the individual files into one larger complete PDF file. </p>

<p>For the converting we are using <a href="https://github.com/cloudify/sPDF" rel="nofollow" title="sPDF"><strong>sPDF</strong></a> which is built on top of <strong><a href="http://wkhtmltopdf.org/" rel="nofollow">wkhtmltopdf</a></strong>. For the merging we use <a href="https://pdfbox.apache.org/docs/1.8.11/javadocs/org/apache/pdfbox/util/PDFMergerUtility.html" rel="nofollow"><strong>PDFMergerUtility</strong></a>. </p>

<p><em>The reasons for making individual files is a bit complicated - but it should be noted we can't make one big PDF off the bat and have to make the individual files first.</em></p>

<h2>The issue</h2>

<p>Initially we had no problems with this approach - however as the system has grown - so have the final PDF files. We went from files that were <strong>2MB-3MB</strong> to files that are <strong>20MB</strong>. I would like to know if there is any obvious compression methods or techniques we could use? </p>

<p><strong>There is a lot of shared content across the individual files</strong> but since we're just merging them as isolated/independent files (as in, none of the content that is the same across the individual files is being reused to save space) it doesn't make a difference in bringing down the file size. </p>

<p>If I manually ZIP the final PDF file it greatly reduces the file size -as obviously there is a lot of repeated content. </p>

<p>So one option might just be to zip the PDF after I've finished the merging, but I would prefer to compress it during the merger process or conversion process.
Any ideas?</p>