This can be done using shinyjs
package to call a js function.
library(shiny)
library(shinyjs)
jsCode <- 'shinyjs.winprint = function(){
window.print();
}'
ui <- shinyUI(fluidPage(
useShinyjs(),
extendShinyjs(text = jsCode, functions = c("winprint")),
actionButton("print", "PRINT")
))
server <- shinyServer(function(input, output) {
observeEvent(input$print, {
js$winprint()
})
})
shinyApp(ui, server)
Hope it helps!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…