browser_print: Print a web page to PDF/PNG/JPEG

View source: R/browser.R

browser_printR Documentation

Print a web page to PDF/PNG/JPEG

Description

Print a web page via a headless browser such as Chromium or Google Chrome.

Usage

browser_print(
  url,
  output = ".pdf",
  args = "default",
  window_size = c(1280, 1024),
  browser = env_option("xfun.browser", find_browser())
)

Arguments

url

Path or URL to the page to be printed.

output

An output filename. If only an extension is provided, the filename will be inferred from url via url_filename(). Only .pdf, .png, and .jpeg are supported.

args

Command-line arguments to be passed to the headless browser. The default arguments can be found in xfun:::browser_args(). You may pass additional arguments on top of these via, e.g., c('default', '--no-pdf-header-footer'), or completely override the default arguments by providing a vector of other arguments.

window_size

The browser window size when printing to PNG/JPEG.

browser

Path to the web browser. By default, the browser is found via xfun:::find_browser(). If it cannot be found, you may set the global option options(xfun.browser = ) or environment variable R_XFUN_BROWSER to the path of the browser, or simply pass the path to the browser argument.

Value

The output path if the web page is successfully printed.

Examples


xfun::browser_print("https://www.r-project.org")


xfun documentation built on Dec. 16, 2025, 9:06 a.m.