title: R shiny how to save uioutput to a pdf file
body: <p>In my Shiny app, I have a uiOutput containing a varying number of ggplots. Now I need a download button to download the uiOutput object as a pdf file. </p>
  
  <p>Here I worked up a simplified piece of sample code below.</p>
  
  <p>How can we edit the ??????? part of the code to make it work?</p>
  
  <pre><code>library(ggvis)
  
  server &lt;- function(input, output) {
  
    output$plot1 = renderPlot({plot(rnorm(100))})
  
    output$plot2 = renderPlot({plot(rnorm(100))})
  
    output$table =renderTable({head(mtcars)})
  
    output$x = renderUI({
      div(
        plotOutput("plot1"),
        plotOutput("plot2"),
        tableOutput("table")
      )
    })
  
  
    output$pdflink &lt;- downloadHandler(
      filename &lt;- "myReport.pdf",
      content &lt;- function(file) {
        src &lt;- normalizePath('report.Rmd')
        owd &lt;- setwd(tempdir())
        on.exit(setwd(owd))
        file.copy(src, 'report.Rmd')
        library(rmarkdown)
  
        out &lt;- render('report.Rmd',pdf_document())
        file.rename(out, file)
      }
    )
  }
  
  ui &lt;- fluidPage(
  
    downloadButton("pdflink","Download Results")
  
  )
  
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>Thanks.</p>