4

I have this latex document comprising many vector graphics (PDF files) representing plots, each one consisting of many small elements.

When I compile it with pdflatex, I end up with a fairly large document of ~12MB. The major issue here, size apart, is that this colossus highly slows down my (and I suppose others') pdf reader (evince on Ubuntu in my case) to the point that is freezes up for some seconds.

This may sound like the average 'reduce pdf size' question here, however I am not getting any help from all the solutions found in all the answers I read. For instance, setting these tex commands does not change a thing:

\pdfminorversion=5
\pdfobjcompresslevel=3 
\pdfcompresslevel=9

I've also looked into all the tools like pdfsizeopt, but since I do not have raster images, I cannot degrade them. Plus, going from my vector images to raster one would mean losing a lot of details.

Up to now, I have found a decent solution with opening the file with evince and print it to pdf again. This dramatically reduces the size to just 4 MB. It preserves the vector quality of all images, and also drastically reduces the rendering time for the pages full of such images. I am wondering if this relates to the fact that by printing it somehow simplifies the vector drawings; like preserving only the objects or their parts which "stay in the front".

However, this may be not what I need in the end. What I am looking for is a way to embed the pdf output file compression directly into the latex pipeline. My major issue is that my sources will be compiled by a third party like a journal or the arXiv, so they will end up with a very big file in the end, which will make reading it painful. And I cannot tell them: "Open evince, then..."

Could I call something like evince from the command line on each image and then embed this preprocessed and optimized versions in my sources? Can I call some command from latex to optimize the output for print (supposing it is doing something like evince did)?

  • 1
    I would use \pdfminorversion=7 although I don't think that will make enough difference. When you print to PDF, can you still search the PDF? How are the images produced? I'm not really clear what you mean by saying they contain 'many small elements'. – cfr Oct 22 '16 at 12:46
  • 1
    What happens if you open the image pdf files with evince, then either resave them or print to a new file and then use these images in latex? [if you printed them to a new file, you might to clip the image to remove the boarders] – user36296 Oct 22 '16 at 13:23
  • @samcarter that is what I was trying to do, but having to clip means heavy editing of the latex source code (more than 50 images here) – rano Oct 22 '16 at 16:04
  • @cfr nothing changes. The images have been produced by python code and are graphics from matplotlib and other scientific libraries. The elements I was referring to are like the dots in a scatterplot: there are many of them and most are just overlapping. By the 'printing optimization' I guess that only the frontmost get drawn actually. In the end I guess I would go to black and white (for the size) hyper HD resolution raster images... – rano Oct 22 '16 at 16:06
  • 1
    Why do you need to edit the LaTeX source if you clip the images? – cfr Oct 22 '16 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.