This function can handle both static Rmd documents and Rmd documents with
runtime: shiny
.
The path to a Rmd document.
A vector of names of output files. Should end with an image file
type (.png
, .jpg
, .jpeg
, or .webp
) or
.pdf
. If several screenshots have to be taken and only one filename
is provided, then the function appends the index number of the screenshot
to the file name. For PDF output, it is just like printing the page to PDF
in a browser; selector
, cliprect
, expand
, and
zoom
will not be used for PDFs.
Other arguments to pass on to webshot
.
Time to wait before taking screenshot, in seconds. Sometimes a longer delay is needed for all assets to display properly. If NULL (the default), then it will use 0.2 seconds for static Rmd documents, and 3 seconds for Rmd documents with runtime:shiny.
A list of additional arguments to pass to either
render
(for static Rmd documents) or
run
(for Rmd documents with runtime:shiny).
Port that Shiny will listen on.
A named character vector or named list of environment variables and values to set for the Shiny app's R process. These will be unset after the process exits. This can be used to pass configuration information to a Shiny app.
Invisibly returns the normalized path to all screenshots taken. The character vector will have a class of `"webshot"`.
if (interactive()) {
# R Markdown file
input_file <- system.file("examples/knitr-minimal.Rmd", package = "knitr")
rmdshot(input_file, "minimal_rmd.png")
# Shiny R Markdown file
input_file <- system.file("examples/shiny.Rmd", package = "webshot")
rmdshot(input_file, "shiny_rmd.png", delay = 5)
}