我正在研究R Sweave
,以在服务器上的shiny
应用程序中生成PDF报告。一切都可以在本地计算机上完美运行,我可以在应用程序中生成PDF。它也可以在服务器中使用。但是,当我想在R Sweave
的背景中添加矩形标题的图像时,该图像在服务器上不再起作用,因此无法生成。
这是我在R Sweave
中添加的代码,所以我的报告:
\usepackage{background}
\usepackage{graphicx}
\backgroundsetup{
scale=0.5,
angle=0,
opacity=1,
color=black,
contents={\begin{tikzpicture}[remember picture, overlay]
\node at ([yshift=-.6in] current page.north)
{\includegraphics[width = \paperwidth]{myheader}};
\end{tikzpicture}}
}
我忘记了什么吗?
谢谢
EDIT:经过一些研究,我认为脚本server.R
中的这些功能可能存在问题:
output$report <- downloadHandler(
filename = function(){name()},
content = function(file) {
out = knitr::knit2pdf(input="my_report.Rnw",encoding = "UTF-8",clean=TRUE)
file.rename(out, file)
file.copy(file,paste0("export/",Sys.Date(),"_",name()))
},
contentType = 'application/pdf'
)
似乎我可能在函数out = knitr::knit2pdf(input="my_report.Rnw",encoding = "UTF-8",clean=TRUE)
中忘记了一个参数。似乎它只能管理UTF-8和几何形式的文本,而不是图像。
问题解决了!在我的R Sweave中,我刚刚添加了\ usepackage {tikz},它可以正常工作!
感谢Dirk Eddelbuettel的帮助。