Learn R Programming

pagedown (version 0.1)

chrome_print: Print a web page to PDF using the headless Chrome (experimental)

Description

This is a wrapper function to execute the command chrome --headless --print-to-pdf url. Google Chrome (or Chromium on Linux) must be installed prior to using this function.

Usage

chrome_print(url, output = xfun::with_ext(url, "pdf"), browser = "google-chrome", 
    extra_args = c("--disable-gpu"), verbose = FALSE)

Arguments

url

A URL or local file path to a web page.

output

The (PDF) output filename. For a local web page foo/bar.html, the default PDF output is foo/bar.pdf; for a remote URL https://www.example.org/foo/bar.html, the default output will be bar.pdf under the current working directory.

browser

Path to Google Chrome or Chromium. This function will try to find it automatically via find_chrome() if the path is not explicitly provided.

extra_args

Extra command-line arguments to be passed to Chrome.

verbose

Whether to show verbose command-line output.

Value

Path of the output file (invisibly).

References

https://developers.google.com/web/updates/2017/04/headless-chrome