# How can I get vectorized text when exporting to pdf?

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];


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

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]


-
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
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

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}}]}]


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.
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