dreamRs / capture

Take screenshots in Shiny apps
https://dreamrs.github.io/capture
GNU General Public License v3.0
32 stars 3 forks source link

capture

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.

Lifecycle: experimental R-CMD-check

Installation

You can install the development version of {capture} from GitHub with:

remotes::install_github("dreamRs/capture")

Features

Take screenshots in your {shiny} applications and {rmarkdown} documents.

Example

In 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().

Related packages

Development

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.