问题
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