Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I have 2D plot, made with DensityListPlot. Mathematica just cannot export them properly to PDF, so what I want to do is 1) export the plot itself, without axes, labels, etc, as a jpg image, and 2) Inset this image in an empty graphics containing only axes, labels etc. So far so good.

The problem is that when I export the final graphics to PDF, the image are not compressed at all -- and the file end up weighing 400k instead of 30k.

The question is: how do I specify the format and compression factor of images embedded in a pdf?

share|improve this question
Rasterize the image first maybe? – fizzics Oct 10 '12 at 10:07
Thanks Chris. I used gs instead of cutepdf to optimise the PDF, and it works very well. Still Wolfram really need to improve PDF export of 2D graphics... – Mammouth Oct 10 '12 at 10:59
Have you taken a look at […, […, […? My guess is that the size of the file is dictated by the JPEG. Have you tried compressing the JPEG that you export? – tkott Oct 10 '12 at 14:01
@Mammouth I'm not quite sure why you believe the raster images aren't compressed, but they most certainly are. If you look in the file you can clearly see the /FlateDecode filter applied to the image stream. This is a lossless compression method so it does not achieve as high a compression ratio as a lossy method (like JPEG). – ragfield Oct 10 '12 at 14:45
@ragfield: fair enough. But how do I tell Mathematica to use jpeg ? – Mammouth Oct 11 '12 at 19:21

Try using EPS as export format (e.g. Export["filename.eps", img], then converting the resulting file to PDF with epstopdf or ps2pdf. This produces much better results than Mathematica's PDF export in most cases.

share|improve this answer
Doesn't solve all problems. – alancalvitti Feb 5 '13 at 0:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.