Add a button in Shiny application or R Markdown document to take a screenshot (PNG or PDF) of a specified element. It uses html-to-image to convert DOM elements to PNG and jsPDF to generate PDF. Doesn't work in IE.
You can install the development version of {capture} from GitHub with:
remotes::install_github("dreamRs/capture")
Take screenshots in your {shiny} applications and {rmarkdown} documents.
capture()
: save as PNGcapture_pdf()
: save as PDFIn UI, use capture()
to save element of the page as PNG:
fluidPage(
capture::capture(
selector = "body",
filename = "all-page.png",
icon("camera"), "Take screenshot of all page"
)
# ...
)
You can create PDF document of the page with capture_pdf()
.
canvas2html
JavaScript
library.This package use {packer} to manage JavaScript assets, see packer's documentation for more.
Install nodes modules with:
packer::npm_install()
Modify srcjs/exts/image.js
or srcjs/exts/pdf.js
, then run:
packer::bundle()
Re-install R package and try capture()
or capture_pdf()
functions.