I have this simplified app:
library(shiny)
library(shinyWidgets)
library(shinyscreenshot)
library(capture)
my_ids <- LETTERS[1:13]
ui <- fluidPage(
#background image
tags$img(
src = "http://upload.wikimedia.org/wikipedia/commons/5/5d/AaronEckhart10TIFF.jpg",
style = 'position: absolute; position: absolute;
width: 1250px; height: 880px;'
),
div(id = "container1",
style="position: absolute;left: 30px; top: 170px; display: inline-block;vertical-align:middle; width: 300px;",
radioGroupButtons(inputId = my_ids[1], label = "", choices = 0:3, selected = 0, checkIcon = list(yes = icon("check")), status = c("zero", "one", "two", "three"))
),
div(style="position: absolute;left: 10px; top: 830px;",
capture::capture(
selector = "body",
filename = "all-page.png",
icon("camera"), "Take screenshot of all page"
))
)
server <- function(input, output, session) {
observeEvent(input$update, {
updateRadioGroupButtons(session = session, inputId = my_ids[1], selected = 0)
}, ignoreInit = TRUE)
}
shinyApp(ui, server)
In this app we have a background picture and the user can press some buttons that will generate a value shown on the background picture. The app works well.
Now I would like to take a screenshot of the picture with all elements on it (like buttons etc. to use it as a report.
How can I do this. I tried shinyscreenshot
and capture
.
I need the screenshot to print as a report on a DIN A4 format.
Here is what I get after numerous trials and errors. This solution uses the JavaScript libraries jspdf and domtoimage.
The result is a pdf file in format A4. Unfortunately, that does not work with the icon.
EDIT
For the icon, you can use this CSS:
and then: