这是非常骇人听闻的,可能掩盖了我有限的 UNIX shell fu,但它适用于安装了pdfjam包的 Fedora 17机器(不是 R 包,而是来自 YUM 存储库)
pdf("pdf1.pdf")
plot(1:10)
dev.off()
pdf("| pdfjoin --outfile \"pdf2.pdf\" && pdfjoin pdf1.pdf pdf2.pdf --outfile pdf1.pdf && rm pdf2.pdf")
plot(10:1)
dev.off()
R中的输出是:
> pdf("| pdfjoin --outfile \"pdf2.pdf\" && pdfjoin pdf1.pdf pdf2.pdf --outfile pdf1.pdf && rm pdf2.pdf")## && pdfunite joined.pdf tmp.pdf joined.pdf && rm tmp.pdf")
> plot(10:1)
> dev.off()
----
pdfjam: This is pdfjam version 2.08.
pdfjam: Reading any site-wide or user-specific defaults...
(none found)
pdfjam: No PDF/JPG/PNG source specified: input is from stdin.
pdfjam: Effective call for this run of pdfjam:
/usr/bin/pdfjam --fitpaper 'true' --rotateoversize 'true' --suffix joined --outfile pdf2.pdf -- /dev/stdin -
pdfjam: Calling pdflatex...
pdfjam: Finished. Output was to 'pdf2.pdf'.
----
pdfjam: This is pdfjam version 2.08.
pdfjam: Reading any site-wide or user-specific defaults...
(none found)
pdfjam: Effective call for this run of pdfjam:
/usr/bin/pdfjam --fitpaper 'true' --rotateoversize 'true' --suffix joined --outfile pdf1.pdf -- pdf1.pdf - pdf2.pdf -
pdfjam: Calling pdflatex...
pdfjam: Finished. Output was to 'pdf1.pdf'.
null device
1
基本上,如果它是唯一的输入文件,pdfjoin
则将从中获取输入,因此我将输出从管道传输到程序并使用参数指定输出文件。然后使用将原始PDF与刚刚创建的连接在一起,指定输出PDF是原始PDF的名称。stdin
pdf()
pdfjoin
--outfile
&&
pdf1.pdf
pdf2.pdf
pdf1.pdf