Have r Shiny app and Rmd file. Trying to download with downloadHandler() but getting an Adobe Acrobat error saying:
"Acrobat could not open 'rstudio-iV1460.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)."
Found that this is due to using Acrobat v11.0 and needing to ensure head of document is formatted with %PDF string.
reference: https://helpx.adobe.com/acrobat/kb/pdf-error-1015-11001-update.html
Question: Where do I put this %PDF and how do I resolve this issue? Do I put it in the Rmd document or in the tex document?
Here is how I'm producing the pdf from the Rmd in my r Shiny app:
server.r
shinyServer(function(input, output) {
# dowload from Rmd file
output$downloadReport <- downloadHandler(
filename = 'input.pdf',
content = function(file) {
src <- normalizePath('input.Rmd')
# temporarily switch to the temp dir, in case you do not have write
# permission to the current working directory
owd <- setwd(tempdir())
on.exit(setwd(owd))
file.copy(src, 'input.Rmd')
library(rmarkdown)
out <- render('input.Rmd', pdf_document())
file.rename(out, file)
}
)
}
input.Rmd
---
always_allow_html: yes
output:
pdf_document:
keep_tex: yes
---
```{r}
test
```
ui.r
fluidPage(
downloadButton('downloadReport')
)
pdf_document()
instead ofhtml_document()
? Have you checked what the contents ofinput.pdf
look like after it is rendered (with, e.g., a text editor)? – r2evans