Skip to content

compress large vector graphics in the "content streams" of PDF files by replacing them with high-quality JP2 raster images

License

Notifications You must be signed in to change notification settings

milahu/pdf-compress-vector-graphics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

pdf-compress-vector-graphics

compress large vector graphics in the "content streams" of PDF files by replacing them with high-quality JP2 raster images

why

as far as i know, currently, no PDF compressor can do this

other PDF compressors can compress only raster images, but fail to compress large vector graphics

large vector graphics

the large vector graphics usually come from tools like "Adobe InDesign"

this is a known issue, see also

high-quality JP2 raster images

high-quality is 600dpi, to produce good quality when printing

JP2 raster images, because JP2 offers better compression than JPG. on the downside, JP2 requires more memory, but most PDF viewers should have enough memory. WEBP raster images are not supported in PDF files

analyze pdf size

offline tools

use ghostscript to split the PDF into text, raster images, vector graphics:

https://stackoverflow.com/questions/29657335/how-can-i-remove-all-images-from-a-pdf

gs -q -o onlyvectors.pdf -sDEVICE=pdfwrite -dFILTERIMAGE -dFILTERTEXT input.pdf
gs -q -o onlytext.pdf -sDEVICE=pdfwrite -dFILTERIMAGE -dFILTERVECTOR input.pdf
gs -q -o onlyimages.pdf -sDEVICE=pdfwrite -dFILTERVECTOR -dFILTERTEXT input.pdf

now compare the file sizes:

du -b input.pdf onlyvectors.pdf onlytext.pdf onlyimages.pdf | sort -n -r

example output:

74258862        input.pdf
52904938        onlyvectors.pdf
743759          onlyimages.pdf
677472          onlytext.pdf

here, onlyvectors.pdf is 70% of input.pdf

online tools

About

compress large vector graphics in the "content streams" of PDF files by replacing them with high-quality JP2 raster images

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages