I came across the problem of optimizing an PDF file output by LaTeX from 60 MB to less than 30 MB to fit the requirement of a submission system. The simplest way is perhaps to use GhostScript to compress the pdf. For example
gswin64c -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -dPDFSETTINGS=/default -sOutputFile=abc_compress.pdf abc.pdf
gswin64c -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -dPDFSETTINGS=/default -sOutputFile=abc_compress.pdf abc.pdf
where abc.pdf is the input file.
There are five settings that one can fiddle to control the trade off between compression ratio and document quality. For images, the more compression we applied, the more downsampling and detail lost one might experience in the output pdf. Here are the settings that can be replaced with /default in the command line above:
- /ebook
- /screen
- /prepress
- /default : largest file size but some compression could still discards image details
- /printer
If you are not satisfied with the default image quality produced by GhostScript, it is possible to control to specify the image encoding we need, for example:
gswin64c -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -dAutoFilterColorImages=false -dEncodeColorImages=true -dColorImageFilter=/DCTEncode -dColorConversionStrategy=/LeaveColorUnchanged -sOutputFile=abc_compress.pdf abc.pdf
where
-dAutoFilterColorImages=false turns off default setting for image compression,
-dColorImageFilter=/DCTEncode specify the compression type to be JPEG compression.
If you don't want any compression, replace /DCTEncode by /FlateEncode.
More documentation about the parameters could be found here.
If you don't like working with command lines, give Adobe Acrobat a try in case you haven't installed any. It's free for trial in 30 days.
Any comments are welcome.
Reference:
1. http://www.volkerschatz.com/tex/hiqpdf.html
2. Adobe Distiller parameters documentation. Some are applicable to GhostScript.
gswin64c -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -dAutoFilterColorImages=false -dEncodeColorImages=true -dColorImageFilter=/DCTEncode -dColorConversionStrategy=/LeaveColorUnchanged -sOutputFile=abc_compress.pdf abc.pdf
where
-dAutoFilterColorImages=false turns off default setting for image compression,
-dColorImageFilter=/DCTEncode specify the compression type to be JPEG compression.
If you don't want any compression, replace /DCTEncode by /FlateEncode.
More documentation about the parameters could be found here.
If you don't like working with command lines, give Adobe Acrobat a try in case you haven't installed any. It's free for trial in 30 days.
Any comments are welcome.
Reference:
1. http://www.volkerschatz.com/tex/hiqpdf.html
2. Adobe Distiller parameters documentation. Some are applicable to GhostScript.
Good post but I was wondering if you could write a litte more on this subject? I’d be very thankful if you could elaborate a little bit further. Appreciate it! compress pdf online
ReplyDelete