shiny htmlOutput() – export to pdf

天大地大妈咪最大 提交于 2021-02-11 00:57:41

问题


I want to export html objects from shiny app to pdf. In order to export table, I was using .Rmd template (based on How to make pdf download in shiny app response to user inputs?), however I do not know how to pass html object to PDF in shiny app.

Example app:

library(shiny)
ui <- shinyUI(
  fluidPage(
    fluidRow(
      column(width=4,
      htmlOutput("Table1"),
      htmlOutput("Table2"),
      htmlOutput("Table3")
    ))
  )
)

server <- shinyServer(function(input, output, session){


  #****************************************
  #* Output Components

  output$Table1 <- renderUI({
    HTML("<div class='progress-group'>
                    <span class='progress-text'>Add Products to Cart</span>
                    <span class='progress-number'><b>160</b>/200</span>
                    <div class='progress sm'>
                      <div class='progress-bar progress-bar-aqua' style='width: 80%'></div>
                    </div>
                  </div>")
  })

  output$Table2 <- renderUI({
    HTML("<div class='progress-group'>
                    <span class='progress-text'>Complete Purchase</span>
         <span class='progress-number'><b>310</b>/400</span>
         <div class='progress sm'>
         <div class='progress-bar progress-bar-red' style='width: 100%'></div>
         </div>
         </div>")
  })

  output$Table3 <- renderUI({
    HTML("<div class='progress-group'>
                    <span class='progress-text'>Visit Premium Page</span>
         <span class='progress-number'><b>480</b>/800</span>
         <div class='progress sm'>
         <div class='progress-bar progress-bar-green' style='width: 10%'></div>
         </div>
         </div>")
  })
})

shinyApp(ui, server)

来源:https://stackoverflow.com/questions/39772774/shiny-htmloutput-export-to-pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!