英文:
Sweave, Shiny : can't generate a PDF on the server
问题
我正在使用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}}
}
我是否忘记了什么?
谢谢
编辑:经过一些研究,我认为我在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编码的文本和几何形状,而不能处理图像。
英文:
I'm working on R Sweave
to generate a report in PDF in a shiny
application on a server. Everything works perfectly in my computer, locally, I can generate my PDF in the application. It also works in the server. But, when I wanted to add an image in a background, a rectangular header, in the R Sweave
, it didn't work anymore on the server, it can't be generated.
Here's the code I added in my R Sweave
, so my report :
\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}}
}
Did I forget something ?
Thank you
EDIT : After some researches, I think I probably have a problem with these functions in the script 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'
)
It seems that I probably forgot an argument in my function out = knitr::knit2pdf(input="my_report.Rnw",encoding = "UTF-8",clean=TRUE)
. It seems that it can only manage a text on UTF-8 and geometric forms, not an image.
答案1
得分: 1
问题解决了!在我的R Sweave中,我只是添加了\usepackage{tikz},然后它就可以工作了!感谢Dirk Eddelbuettel的帮助。
英文:
Problem solved! In my R Sweave, I just added \usepackage{tikz} and it works!
Thanks to Dirk Eddelbuettel for his help.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论