使用ggplot ggsave将文本另存为曲线

时间:2012-11-24 15:15:20

标签: r pdf-generation

以下代码将在PDF文件

中创建一个图表
library(ggplot2)

ggplot(data=mtcars, aes(x=cyl, y=hp))+
  geom_point() +
ggsave(filename="test1.pdf")

只有极少数字符,但只要它们不是曲线,它们就是脆弱的。 我想保留外表。

$ pdffonts test1.pdf 
name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
ZapfDingbats                         Type 1            no  no  no      10  0
Helvetica                            Type 1            no  no  no      11  0

如何将文字和符号转换为曲线?

running R 2.15 on debian squeeze

picture explaining what text-to-curves表示

1 个答案:

答案 0 :(得分:2)

https://tex.stackexchange.com/questions/27327/how-to-convert-text-in-a-pdf-file-from-fonts-text-to-outlines复制:我调用了此脚本pdfsquash

#!/bin/sh

if [ "x$1" = "x" -o "x$2" = "x" ]; then
    echo Usage: `basename "$0"` "<input.pdf>" "<output.pdf>" >&2
    exit 1
fi
gs -sDEVICE=pswrite -dNOCACHE -sOutputFile=- -q \
   -dbatch -dNOPAUSE -dQUIET "$1" -c quit | ps2pdf - "$2"

我运行了你的代码,然后(在R之外,虽然你也可以使用system()):

pdfsquash test1.pdf test1S.pdf

原文:

pdffonts test1.pdf
name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
ZapfDingbats                         Type 1            no  no  no      10  0
Helvetica                            Type 1            no  no  no      11  0

新:

pdffonts test1S.pdf
name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
相关问题