我曾经能够将来自 URL 的图像包含在由闪亮的应用程序生成的 PDF 报告中![](url.com)
。几个 markdown 版本之后我收到以下错误:! Unable to load picture or PDF file https://i0.wp.com/wptavern.com/wp-content/uploads/2016/07/stack-overflow.png?ssl=1
对于相同的代码。Adding https://stackoverflow.com/questions/52558238/image-file-not-found-from-url-in-r-markdown pandoc_args: ["--extract-media", "."]
to the YAML
将镜像文件下载到本地,但仅在本地有效r-markdown
files.
- shinyapp如何存储本地文件以及如何获取
extract-media
解决方法才能发挥作用?
- 如何在shinyapps中将网页图像包含在PDF文件中?
r-markdown 示例
title: "Test"
header-includes:
- \usepackage{graphicx}
- \usepackage{hyperref}
output:
pdf_document:
latex_engine: xelatex
pandoc_args: ["--extract-media","."]
number_sections: yes
keep_tex: yes
classoption: article
papersize: A4
fontsize: 10pt
geometry: margin=0.9in
linestretch: 1.15
---
## R Markdown
![click](https://i0.wp.com/wptavern.com/wp-content/uploads/2016/07/stack-overflow.png?ssl=1)
server.R chunk 触发报告生成
## img report
output$downloadImgReport <- downloadHandler(
filename = function() {
paste0(format(Sys.time(), '%Y%m%d'),'-WS-CM-image-report-',docounts()$count, '.pdf')
},
content = function(file) {
src <- normalizePath('Untitled.Rmd')
src1 <- normalizePath('logo.png')
owd <- setwd(tempdir())
on.exit(setwd(owd))
file.copy(src, 'Untitled.Rmd', overwrite = TRUE)
file.copy(src1,'logo.png')
library(rmarkdown)
out <- render('Untitled.Rmd', output_format=pdf_document(latex_engine = "xelatex"))
writetolog(1,session$token)
file.rename(out, file)
}
)