https://github.com/dreamRs/capture
Take screenshots in Shiny apps
https://github.com/dreamRs/capture
Last synced: 3 months ago
JSON representation
Take screenshots in Shiny apps
- Host: GitHub
- URL: https://github.com/dreamRs/capture
- Owner: dreamRs
- License: gpl-3.0
- Created: 2020-09-23T09:37:08.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-18T12:26:10.000Z (5 months ago)
- Last Synced: 2024-09-19T12:05:42.755Z (5 months ago)
- Language: JavaScript
- Homepage: https://dreamrs.github.io/capture
- Size: 11.6 MB
- Stars: 30
- Watchers: 3
- Forks: 4
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: NEWS.md
- License: LICENSE.md
Awesome Lists containing this project
- jimsghstars - dreamRs/capture - Take screenshots in Shiny apps (JavaScript)
README
# 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](https://github.com/bubkoo/html-to-image) to convert DOM elements to PNG and [jsPDF](https://github.com/parallax/jsPDF) to generate PDF. Doesn't work in IE.
[](https://lifecycle.r-lib.org/articles/stages.html)
[](https://github.com/dreamRs/capture/actions/workflows/R-CMD-check.yaml)## Installation
You can install the development version of {capture} from GitHub with:
```r
remotes::install_github("dreamRs/capture")
```## Features
Take screenshots in your [{shiny}](https://shiny.rstudio.com/) applications and [{rmarkdown}](https://rmarkdown.rstudio.com/) documents.
* `capture()`: save as PNG
* `capture_pdf()`: save as PDF## Example
In UI, use `capture()` to save element of the page as PNG:
```r
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](https://github.com/daattali/shinyscreenshot) (on CRAN): Capture screenshots of entire pages or parts of pages in Shiny apps
* [snapper](https://github.com/yonicd/snapper) : snap images of html objects in Shiny apps using `canvas2html` JavaScript
library.## Development
This package use [{packer}](https://github.com/JohnCoene/packer) to manage JavaScript assets, see packer's [documentation](https://packer.john-coene.com/#/) for more.
Install nodes modules with:
```r
packer::npm_install()
```Modify `srcjs/exts/image.js` or `srcjs/exts/pdf.js`, then run:
```r
packer::bundle()
```Re-install R package and try `capture()` or `capture_pdf()` functions.