You are not logged in.
Pages: 1
Just wondering if you can set the level of deflate compression (zlib) in a PDF ie level 1 - 9 and if so how you can do that in code?
Offline
By default, the level is 7.
See
procedure TPdfStream.InternalWriteTo(var W: TPdfWrite);
(...)
try
TmpSize := CompressStream(TMemoryStream(FWriter.fDestStream).Memory,
TmpSize,TmpStream,7,true);
(...)
You can change 7 here by whatever number.
What's wrong with 7?
Offline
Thank you for that. I am just trying to squeeze the pdf down as much as I can as we have terrible internet speeds at work and the pdf's can be large.
thanks again for your great work
Offline
I'm note sure you'll see a huge difference between 7 and 9 (which is the best method).
At least, on file size.
But on production speed, 9 is much slower than 7.
I'm not sure it's worth it. But you may try your best!
You should better use JPEG compression for the bitmaps, or not embed true type fonts.
Offline
I tried out the level 9 compression and it worked great and created a file about 10% smaller. I did experiment with jpeg but it was not as good with black and white 1 bit bitmaps and produced larger files. I think for color images, you are certainly right suggesting jpeg as the best option.
Once again thank you for you great effort in making this great tool and your quick help.
Offline
Hello,
At least I had on problem with very similar jpeg pictures, that there is no compression of whole file, it compressed very very well with any compressor. Because it contained very similar jpeg files (or at least I tried to compress it in jpeg, and it got smaller...)
I don't know is there an option to compression for the whole file, in Pdf...
.-TP-.
Offline
I don't know is there an option to compression for the whole file, in Pdf...
You can compress not the whole file (the catalog e.g. should be uncompressed), but at least some objects content at once. For the pictures, I'm not sure it's feasible.
I was never able to find out in the PDF reference document how to compress the whole content at once.
I remember that it's feasible since revision 1.7 of the format.
If you have some ideas, could be nice to implement...
Offline
From what I understand CCITT 4 is a very good option for black and white images and produces smaller files, but I have no idea as to how hard that is to implement.
Offline
It appears that the specifications for FAX ccit 4 are here http://www.itu.int/rec/T-REC-T.6-198811-I/en but I am not sure how they are implemented or stored in a PDF. If only we all had more time to do the thing we want. We are all time poor and wealthy in trivia that takes out time
Offline
Hi. If someone is interested, ASyncPro (open source, http://sourceforge.net/projects/tpapro/) implements G3 compression (procedure acCompressRasterLine in AwFaxCvt.pas). As I understand it, G3 is a special case of G4 (CCITT 4), so it should work and should result in a good compression for pdfs with bitonal images, but unfortunately I was not able to use it to generate valid pdfs.
Last edited by hobbist (2015-02-01 05:38:01)
Offline
In addition to my last post, there is also a lossless jbig2 free implementation, with a much better compression than CCITT, used in rubypdf, in http://soft.rubypdf.com/software/lossle … mic-libary.
Offline
Pages: 1