Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Consider this code:

data = Table[Sin[j^2 + i], {i, 0, Pi, Pi/3}, {j, 0, Pi, Pi/3}];
p1 = Graphics[Raster[data], Frame -> True, FrameStyle -> Large, 
  ImageSize -> 300];
p2 = ListDensityPlot[data, InterpolationOrder -> 0, 
  ColorFunction -> "GrayTones", Frame -> True, FrameStyle -> Large, 
  ImageSize -> 300];
Export["~/Downloads/1.pdf", p1, ImageResolution -> 100]
Export["~/Downloads/2.pdf", p2, ImageResolution -> 100]

Why does the font in the first plot appear vectorized while the the font in the second does not?

enter image description here enter image description here

Update:

remove the ImageResolution option will vectorize both plots, but ImageResolution is very helpful in reducing the pdf file size and I can't give up on that.

Export["~/Downloads/1.pdf", p1]
Export["~/Downloads/2.pdf", p2]

enter image description here enter image description here

share|improve this question
1  
This is not an answer, but the same thing happens when exporting these graphics as EMF or WMF. –  Verbeia Jun 20 '13 at 4:47
1  
Possible duplicate of this question. –  m_goldberg Jun 20 '13 at 10:49
    
version or system issue? I get vectors in both cases w/v9 on windows. –  george2079 Jun 20 '13 at 17:29
    
By the way, exporting to EPS i see in both cases the entire file is 'vector', i.e. each square is drawn and filled. You might try exporting eps and converting externally. –  george2079 Jun 20 '13 at 17:40

1 Answer 1

A possible answer to the question in the title, "How can I get vectorized text when exporting to pdf?" is the same as what I suggested here:

rasterTrick[plot_] := 
 Show[plot, 
  Prolog -> {Opacity[0], Texture[{{{0, 0, 0, 0}}}], 
    VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}}, 
    Polygon[{{0, 0}, {.1, 0}, {.1, .1}}]}]

Export["~/Downloads/1.pdf", p1 // rasterTrick]

The function rasterTrick is described in the linked answer, and you'll notice that the white lines between the exported gray squares are gone. The density plot has been turned into a bitmap at high resolution, but the frame labels are not rasterized.

So the Export command just needs to be augmented by //rasterTrick.

share|improve this answer
    
Thanks for the help, but the problem seems to be the ImageResolution options. Only use Export["~/Downloads/2.pdf", p2], the frame labels are also not rasterized. –  xslittlegrass Jun 20 '13 at 17:27
    
Yes, that's correct. But your reason for adding ImageResolution is to get a better quality density plot, without the white lines, right? I see no other reason to use ImageResolution in the first place. My trick achieves this improvement in quality, as if you had used ImageResolution -> 200, but it applies rasterization only to the plot contents and not to the axes or frames. It's a hack that I discovered by accident, but it's better than ImageResolution here. –  Jens Jun 20 '13 at 17:51

Your Answer

 
discard

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.