Skip to content

Commit

Permalink
updated readme + vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Dec 23, 2021
1 parent 51620e6 commit 785a314
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,24 @@ You can create PDF document of the page with `capture_pdf()`.
* [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.


31 changes: 28 additions & 3 deletions vignettes/rmarkdown.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ vignette: >
%\VignetteEncoding{UTF-8}
---


```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
Expand All @@ -20,23 +21,47 @@ library(capture)

{capure} allow to take screenshots in R Markdown documents in HTML format.



## All page

Capture a screenshot of the entire page with:

```{r}
capture(
selector = "body",
filename = "my-document",
"Take screenshot",
button_class = "btn btn-primary btn-block"
)
```

If you want a PDF as output, you can use `capture_pdf()`.



## leaflet map

For example, save the map as PNG:

```{r}
capture("#my-map", "map", "Save map as PNG")
capture("#map-and-code", "map", "Save map and code as PNG")
capture("#only-map", "map", "Save only map as PNG")
```

::: {#my-map}
::: {#map-and-code}
```{r map}
library(leaflet)
leaflet(width = "100%") %>%
leaflet(width = "100%", elementId = "only-map") %>%
addTiles() %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
```
:::


## dygraph chart

Or with a {dygraph} chart:

```{r}
Expand Down

0 comments on commit 785a314

Please sign in to comment.