title: Export content of main panel to PDF file in Shiny
body: <p>I have created a Shiny app involving a simple sidebar layout. The main panel contains four plots and a table which are created and rendered according to certain user-specified parameters. I am trying to add a "download button" so that the user can download (and/or print) all these plots and tables displayed on the main panel. So far I have found this for ui.R</p>
  
  <pre><code>conditionalPanel(
      condition = "input.returnpdf == true",
      strong("PDF size (inches):"),
      sliderInput(inputId="w", label = "width:", min=3, max=20, value=8, width=100, ticks=F),
      sliderInput(inputId="h", label = "height:", min=3, max=20, value=6, width=100, ticks=F),
      br(),
      downloadLink('pdflink')
    )
  </code></pre>
  
  <p>and this for server.R</p>
  
  <pre><code>plotInput &lt;- reactive({
  if(input$returnpdf){
    pdf("plot.pdf", width=as.numeric(input$w), height=as.numeric(input$h))
    plot(rnorm(sample(100:1000,1)))
    dev.off()
  }
  plot(rnorm(sample(100:1000,1)))
  })
  
  output$myplot &lt;- renderPlot({ plotInput() })
  output$pdflink &lt;- downloadHandler(
   filename &lt;- "myplot.pdf",
   content &lt;- function(file) {
     file.copy("plot.pdf", file)
   }
  )
  </code></pre>
  
  <p>but that does not quite work. How can I modify such code so that R takes a "screenshot" of the whole current main panel and exports it to a PDF file?</p>