0
擁有r Shiny應用程序和Rmd文件。嘗試使用downloadHandler()下載,但獲得Adobe Acrobat錯誤說:使用新的Adobe Acrobat 11.0在Shiny中將.Rmd轉換爲PDF
「Acrobat無法打開'rstudio-iV1460.pdf',因爲它不是支持的文件類型或文件已損壞(例如,它是作爲電子郵件附件發送的,未被正確解碼)。「
發現這是由於使用Acrobat v11.0並需要確保文檔的頭部使用%PDF字符串進行格式化。
參考:https://helpx.adobe.com/acrobat/kb/pdf-error-1015-11001-update.html
問:我應該把這個PDF%以及如何解決這個問題?我是將它放在Rmd文檔還是tex文檔中?
這裏是我如何生產從RMD中的PDF在我 - [R閃亮的應用程序:
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()'而不是'html_document()'嗎?在渲染完成後(例如使用文本編輯器),你檢查過「input.pdf」的*內容*嗎? – r2evans
是的,我應該使用pdf_document()。它似乎還需要一些額外的LaTex軟件包。它現在有效。謝謝。 – JL82559