I was doing this for a thesis with 50+ plots and so still wanted compilation to be fast. Oh didn't know about the improved type 42 font support in the new matplotlib! That's good to know and I should check it out.Īnd good point, the PGF works just as well (results should be identical), but since all the plot information has to be compiled by latex, it ends up ballooning the compilation time of the tex doc and the matplotlib PGF page suggests that you can run into memory issues as well. LaTeX then handles all the text rendering (which results in nice looking figures!), so each font is only included once in the final PDF. For this, I use a custom matplotlib backend that creates a PDF file with no text, together with a PGF file that specifies the position of each text. Most of the fonts end up being duplicates. When including many PDF plots into a large LaTeX document, each PDF still comes with embedded fonts, which can increase the file size of the final PDF. just subset fonts in a PDF file, as well as processing a PDF to remove redundant fonts.
Still, I wish there was a good way or script to e.g. If it's bigger, it just uses the original PDF.įor files with lots of points, I've found that rasterizing just the points artist is a good solution (everything else in the plot is still vector), which allows for ghostscript to subset the type 42 fonts without the file-size explosion due to the points. So I use a similar ghostscript script, but one that also checks if the resulting file is actually smaller. I've also found that if you use type 42 fonts (helpful if submitting to a conference where the submission system doesn't accept type 3 fonts), matplotlib will not subset the font, resulting in increased file sizes. I recall something to do with xobject re-use. circles, where as ghostscript seemingly cannot / chooses not to (?). In particular, matplotlib plots that use points (markers) blow up in size quite a bit after processing through ghostscript, due to the way matplotlib re-uses spline information to draw the e.g. Ghostscript is great most of the time, but as mkl points out, it can make some PDFs bigger. Of course, if nothing really reduces the size of the PDF while maintaining adequate quality, you just might want or need to consider simplifying the content itself.Oh man, I've been down the rabbit hole of reducing matplotlib PDF sizes too many times.
If you properly export your PDF file and make prudent use of the points listed above, the tools available in Acrobat will be of minimal benefit to you in reducing your PDF file size with the least amount of lossiness. Note that this option can backfire on you if you repeat the same image multiple times in your document with different cropping. This option only includes the part of any images used by your InDesign document that actually are visible on output due to cropping within a frame. (5) Check the Crop Image Data to Frames option. This option is non-lossy and can achieve significant compression for content that is not raster image-based. (4) Make sure to check the Compress Text and Line Art option. Changing the Image Quality from Maximum to High or even Medium may yield acceptable results, but you should experiment. Typically, the predefined export options use Automatic (JPEG) Maximum quality compression. (2) Choose export options that use lossier compression for raster images. However, for less critical printing and/or viewing on lower resolution monitors, 150 dpi to 200 dpi may be adequate and could dramatically cut PDF file size. This is perfectly fine for PDF files being printed on high quality devices or that may be viewed on large 4K ultra high definition monitors. For example, the predefined print-oriented export options (i.e.joboptions) downsample images to 300 dpi for images over 450 dpi. (1) Choose export options that downsample images to lower resolutions. To answer your specific question, you most effectively reduce PDF file size as follows when you export your PDF file from InDesign as follows: