screenshot: Take a screenshot in shiny apps

Description Usage Arguments Value Examples

View source: R/screenshot.R

Description

Take a screenshot of the whole page and save encoded DataURI that can be accessed via input[[inputId]].

Usage

1
screenshot(inputId, session = shiny::getDefaultReactiveDomain())

Arguments

inputId

the input id where the screenshot should be

session

shiny session

Value

None. However, the screenshot results can be accessed from shiny input

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
library(shiny)
library(dipsaus)
ui <- fluidPage(
  tagList(
    shiny::singleton(shiny::tags$head(
      shiny::tags$link(rel="stylesheet", type="text/css", href="dipsaus/dipsaus.css"),
      shiny::tags$script(src="dipsaus/dipsaus-dipterix-lib.js")
    ))
  ),
  actionButtonStyled('do', 'Take Screenshot'),
  compoundInput2('group', label = 'Group', components = list(
    textInput('txt', 'Enter something here')
  ))
)

server <- function(input, output, session) {
  observeEvent(input$do, {
    screenshot('screeshot_result')
  })
  observeEvent(input$screeshot_result, {
    showModal(modalDialog(
      tags$img(src = input$screeshot_result, width = '100%')
    ))
  })
}

if(interactive()){
  shinyApp(ui, server)
}

dipsaus documentation built on Sept. 6, 2021, 5:08 p.m.