I am not yet sure how I can compress the Content Stream.
In my test I am creating a new PDF with compression options set, and then adding each page of the source PDF to the new PDF.
The compression settings seem to have no effect. The PDF files are the same size.
Code:
PdfDocument outputDocument = new PdfDocument();
outputDocument.Options.NoCompression = false;
outputDocument.Options.CompressContentStreams = true;
outputDocument.Options.FlateEncodeMode = PdfFlateEncodeMode.BestCompression;
UPDATE:
My testing method definitely works. I performed the same steps but with compression set to off for the new PDF. The new PDF was double the size. I then took the uncompressed PDF and can it again but with compression on. The new PDF was the same size as my original compressed PDF.
So I guess it comes down to the compression method being not that great for PDF's?
Maybe Flate is the best it can currently do. I compared the PDF's in a binary editor and I can see the portions being compressed. Though there seems to be so much room for improvement by Adobe for compressing PDF's.
Oh well... I guess further file size reduction is beyond what is available in the PDF spec.