Buttons to populate snapper_div or download to local file the canvas contents.

preview_button(
  inputId = "btn-Preview-Image",
  label = "Preview",
  ui = "#html-content-holder",
  previewId = "previewImage",
  opts = config()
)

preview_link(
  inputId = "btn-Preview-Image",
  label = "Preview",
  ui = "#html-content-holder",
  previewId = "previewImage",
  opts = config(),
  icon = "camera"
)

download_button(
  inputId = "btn-Convert-Html2Image",
  label = "Download",
  ui = "#html-content-holder",
  filename = "canvas.png",
  opts = config()
)

download_link(
  inputId = "btn-Convert-Html2Image",
  label = "",
  ui = "#html-content-holder",
  filename = "canvas.png",
  opts = config(),
  icon = "camera"
)

Arguments

inputId

character, The input slot that will be used to access the value. Default: 'btn-Preview-Image'

label

character, The contents of the button. Default: 'Preview'

ui

character, The jQuery selector of the target ui element to be captured. Default: '#html-content-holder'

previewId

character, The id that is mapped to the container that captures the canvas output. Default: 'previewImage'

opts

configuration settings to pass to html2canvas.

icon

icon to pass use for in the link objects, Default: 'camera'

filename

character, Local path to save the image. Default: 'canvas.png'

Value

shiny.tag

Details

Use config to define the configuration options

See also

actionButton

Other elements: snapper_div()

Examples

if(interactive()){ options(device.ask.default = FALSE) ui <- fluidPage(id = 'page', # load snapper into the app load_snapper(), titlePanel("Hello Shiny!"), sidebarLayout( sidebarPanel(id = 'side', # add id to side panel sliderInput("obs", "Number of observations:", min = 0, max = 1000, value = 500), # add a download button for the side panel by id snapper::download_button(ui = '#side', label = 'Download Side Panel', filename = 'side_panel.png'), # add a preview button for the side panel by id snapper::preview_button(ui = '#side', previewId = 'preview_side', label = 'Preview Side Panel'), # add a preview button for the main panel by id snapper::preview_button(ui = '#main', previewId = 'preview_main', label = 'Preview Main Panel') ), # Show a plot of the generated distribution mainPanel(id = 'main', # add id to main panel plotOutput("distPlot"), # create a div that will display the content created by preview_side shiny::tags$h3('Preview Side Panel'), snapper::snapper_div(id = 'preview_side'), # create a div that will display the content created by preview_main shiny::tags$h3('Preview Main Panel'), snapper::snapper_div(id = 'preview_main') ) ) ) server <- function(input, output) { output$distPlot <- renderPlot({ hist(rnorm(input$obs)) }) } # Complete app with UI and server components shinyApp(ui, server) }