Skip to content

dreamRs/capture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

802a55d · Oct 26, 2024

History

45 Commits
Jul 5, 2023
Sep 30, 2024
Sep 30, 2024
Sep 18, 2024
Sep 30, 2024
Sep 18, 2024
Dec 23, 2021
Dec 22, 2021
Dec 22, 2021
Oct 26, 2024
Sep 23, 2020
Dec 22, 2021
Sep 18, 2024
Jul 5, 2023
Sep 30, 2024
Jul 5, 2023
Jul 5, 2023
Dec 22, 2021
Dec 22, 2021
Dec 22, 2021

Repository files navigation

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.

  • 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.