我试图将多个pdf图形合并成一个主pdf文件。
例如:
输入:我有三个pdf文件:“1.pdf”,“2.pdf”和“3.pdf”
输出:如何将这三个图形合并为一个名为“combine.pdf”的文件
我尝试使用pdf()和pdftk(),但还没有成功,可能是我错过了一些简单的东西。想要请求帮助。非常感激任何回应。
我试图将多个pdf图形合并成一个主pdf文件。
例如:
输入:我有三个pdf文件:“1.pdf”,“2.pdf”和“3.pdf”
输出:如何将这三个图形合并为一个名为“combine.pdf”的文件
我尝试使用pdf()和pdftk(),但还没有成功,可能是我错过了一些简单的东西。想要请求帮助。非常感激任何回应。
devtools
包下载它。请注意,您必须安装并将ghostscript添加到路径中才能使其正常工作:
## 获取plotflow github包:
library(devtools)
install_github("plotflow", "trinker")
library(plotflow)
## 使用该软件包合并多个pdf的两个示例
## Example 1
merge_pdf(3, file = "foo.pdf", widths = c(7, 7, 10), heights = c(6, 10, 7))
plot(1:10)
plot(1:10, pch=19)
plot(1:10, col="red", pch=19)
## Example 2
library(ggplot2)
p <- ggplot(mtcars, aes(factor(cyl), mpg)) + geom_boxplot()
merge_pdf(2, file = "bar.pdf", widths = c(7, 10), heights = c(6, 10))
plot(1:10)
print(p)
您可以使用sweave/knitr
来获得更多的灵活性,并轻松地合并新的图形、旧的图形和文本:
\documentclass{article}
\usepackage{pdfpages}
\begin{document}
this my plot 1: % write some texts here
\includepdf{1.pdf}
this my plot 2:
\includepdf{2.pdf}
this my plot 3:
\includepdf{3.pdf}
this my plot 4:
\includepdf{4.pdf}
a new plot:
<<echo=FALSE>>= % chunk for new plots
x <- rnorm(100)
hist(x)
@
\end{document}
在Linux中使用命令行提示符,如果您在同一目录中且.pdf文件按您想要的顺序排列,则可以使用以下命令:
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=Chart_Pak.pdf *.pdf
shell_exec("gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFFitPage -sPAPERSIZE=a4 -dFIXEDMEDIA -sOUTPUTFILE= abc.pdf xyz.pdf");
R
的输入,你需要使用PDF编辑器。 - Señor O