Reputation: 54
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.
Upvotes: 0
Views: 182
Reputation: 54
Problem solved! In my R Sweave, I just added \usepackage{tikz} and it works!
Thanks to Dirk Eddelbuettel for his help.
Upvotes: 1