I have a problem getting this to work. I can use the code In have outside of a shiny module and it works as designed. But When I embed the same code in a shin module I cannot get it to work. I am using Using Shiny Modules to simplify building complex apps | Trusted Data Sharing Network | Digital Research Environment as a guide.
Here is a dumbed down version that exhibits the same behavior: (apparently I cannot upload .Rmd or .R files and this formats the code horribly)
App:
library(shiny)
library(DT)csvDownloadUI <- function(id, label = "Download CSV") {
ns <- NS(id)downloadButton(ns("download"), label)
}csvDownload <- function(input, output, session, reportName) {
tempReport <- file.path(tempdir(),reportName)
file.copy(reportName, tempReport, overwrite = TRUE)
output$pdfGen <- downloadHandler(
filename = function() { "report.pdf" }, content = function(file) { rmarkdown::render(tempReport, output_file = file, envir = new.env(parent = globalenv()) ) }
)
}server <- function(input, output, session) {
callModule(csvDownload, "download_filtered","reportTest.Rmd")
}
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
csvDownloadUI("download_filtered", "Download PDF Report")
),
mainPanel()
)
)shinyApp(ui=ui,server=server)
Rmd:
---
output:
pdf_document:
latex_engine: pdflatex
header-includes:
- \usepackage{pdflscape}
- \newcommand{\blandscape}{\begin{landscape}}
- \newcommand{\elandscape}{\end{landscape}}
always_allow_html: yes
fontsize: 12pt
geometry: margin=0.75in
sansfont: Clibri Light
fig_width: 3
fig_heigth: 2
---
\begin{center}
\bfseries\LARGE A Risk Analysis Report for Today
\end{center}
\begin{center}
\bfseries\Large Authored by: JCH
\end{center}
\begin{center}
\bfseries\Large Now
\end{center}
<br> </br>
<br> </br>
<br> </br>
The IIO Parameter is 4