Skip to content

dreamRs/capture

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
R
 
 
 
 
 
 
man
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 build status

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.

  • capture(): save as PNG
  • capture_pdf(): save as PDF

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

  • shinyscreenshot (on CRAN): Capture screenshots of entire pages or parts of pages in Shiny apps
  • snapper : snap images of html objects in Shiny apps using canvas2html JavaScript library.

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.