Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For most R users, webshot2::webshot() is the simplest way to turn a web page into a PNG: install the package and a Chromium-based browser, then capture a URL or local HTML file. Use pagedown::chrome_print() when browser-based printing is already part of your workflow, or Chromote directly when you need to control a browser session in more detail.

How the conversion works

R does not ordinarily render a web page into a PNG by itself. These approaches open the HTML in a browser engine, let that engine lay out the page, and save a screenshot. That means the result depends on the browser environment and on when the page is captured: HTML that relies on JavaScript, remote images, fonts, or other network resources may look different or remain incomplete if those resources have not loaded.

For a routine capture, start with webshot2. Its project documentation describes it as a replacement for the older webshot package, using headless Chrome through Chromote rather than PhantomJS. You will need both the R package and a Chrome or other Chromium-based browser installed.

Convert a URL or HTML file with webshot2

Install the package and browser

Install the CRAN package from R, and ensure a compatible browser is installed on the computer or server where the R code will run:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
install.packages("webshot2")

The package uses headless Chrome through Chromote. Install Google Chrome, Chromium, Microsoft Edge, or another Chromium-based browser if you do not already have one. On a server, container, or automated build system, installing the R package alone is not enough: the browser must also be available to the process running R. Browser installation and system dependencies vary by operating system and deployment environment.

Capture a URL

Call webshot() with the page address and an output filename ending in .png:

webshot2::webshot("https://www.r-project.org/", file = "page.png")

The file is written in the R process’s current working directory unless you give it another path. To check that directory, run getwd(); to choose a destination, pass a path such as file = "output/page.png". The destination directory must already exist.

Capture local HTML

For an HTML document saved on disk, pass its path as the input and choose a PNG destination:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
webshot2::webshot("report.html", file = "report.png")

If the document refers to local images, CSS, or scripts using relative paths, keep the directory structure the document expects. A local page may not render the same way if its referenced files cannot be found. For an R Markdown report, render it to HTML first, then capture the resulting HTML file with webshot2; alternatively, use pagedown::chrome_print() with the rendered document as its input.

Choose the captured size and region

A screenshot is an image of a browser-rendered layout, so decide whether you want the page as seen in a viewport or a particular region. webshot2::webshot() documents controls including viewport dimensions, selector capture, clipping, expansion, delay, and zoom. Confirm the accepted argument names and defaults in the help for the package version installed on your system: ?webshot2::webshot.

  • Viewport size: Set vwidth and vheight to control the virtual browser window. Page layout can change at different widths because responsive sites rearrange content at breakpoints.
  • Viewport-only output: Use cliprect = "viewport" when you want the visible browser viewport rather than the full page.
  • One element: Use the documented selector option when you want a specific page element instead of the whole page. The selector must match an element that exists when the capture runs.
  • Clipping and expansion: Use clipping controls to define a region, and consult the function reference for how cliprect and expand interact in your installed version.
  • Timing: Increase the documented delay when a page needs additional time after loading to finish drawing or updating. There is no universal delay that guarantees every site’s content is ready.
  • Zoom: Use the documented zoom control when you need to change the effective scale of the capture; check the help for the installed package for its exact behavior.

Here is a starting example with an explicit viewport and a delay:

webshot2::webshot(
  "https://example.org",
  file = "example.png",
  vwidth = 1280,
  vheight = 900,
  delay = 2
)

The two-second delay in this example is only a starting value, not a guarantee that a particular page has finished loading. Choose a delay based on the page and inspect the resulting image. For repeatable work, keep the browser version, viewport, input page, and capture settings consistent.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Capture multiple pages

webshot2 accepts a vector of URLs and can capture multiple pages in parallel. Give every input a corresponding output path so you can identify each result:

urls <- c(
  "https://example.org/",
  "https://www.r-project.org/"
)
files <- c("example.png", "r-project.png")

webshot2::webshot(urls, file = files)

For a batch, check the package reference for the filename behavior and parallel-capture controls supported by your installed version. A page that is slow, unavailable, or dependent on a particular browser state can behave differently from the other pages in the same batch. If one output is missing or incomplete, try that URL individually to isolate the issue.

When pagedown or Chromote is a better fit

Use pagedown for browser printing workflows

pagedown::chrome_print() accepts a URL or local HTML path, and it can also work with an HTML file rendered from R Markdown. Its format argument supports PNG and JPEG as well as PDF. It communicates with Chrome through the Chrome DevTools Protocol and requires Google Chrome, Microsoft Edge, or Chromium.

pagedown::chrome_print(
  input = "report.html",
  output = "report.png",
  format = "png"
)

The function reference documents controls including wait, selector, box_model, and scale. Use wait when the page needs more time before capture; use a selector or box-model settings when the desired output is limited to an element or region. Confirm syntax and defaults with ?pagedown::chrome_print, especially if you are adapting an existing PDF workflow.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Use Chromote for direct browser-session control

Chromote is a lower-level choice when you want to create a browser session, navigate it, and then decide what to capture. Its screenshot API supports selector and region capture, clipping, scale, delay, and PNG, JPEG, or WebP output. The filename determines the format, with PNG as the default.

b <- chromote::ChromoteSession$new()
b$go_to("https://example.org")
b$screenshot("example.png", selector = "body")

This approach gives you direct access to a browser session, but requires more explicit session setup than a one-call webshot2::webshot() capture. Choose it when that session control is useful, not because the documentation establishes that it is faster or produces more faithful images; no controlled comparison of speed, fidelity, or success rates is established here.

Keep older webshot code only when its setup is understood

The older webshot package also documents URL screenshots, output paths, viewport dimensions, and clipping. It is a legacy option rather than the first choice for a new workflow: the webshot2 project describes its switch from PhantomJS to headless Chrome via Chromote. Before changing an existing project, check its dependencies and system setup, and verify that the new package’s behavior meets that project’s needs.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you have a public URL and do not need to run a browser locally, ScreenshotNeo provides a screenshot API. This example saves the response as WebP; the API also returns PNG, JPEG, or PDF when configured for those formats. See the ScreenshotNeo API documentation for request options.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.org -o shot.webp

ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. ScreenshotNeo is an API alternative to local R rendering, not an R package: this example captures a URL and does not convert an arbitrary local HTML file on your computer.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Troubleshooting incomplete or failed captures

  • R reports that no browser is available: Install a Chrome/Chromium-based browser on the same machine or environment where R runs. A browser installed on your desktop will not satisfy a job running inside a separate container or server.
  • The output directory does not exist: Create it before calling webshot(), or write to a filename in the current working directory. Check the working directory with getwd().
  • The PNG is blank or missing dynamic content: The page may not have completed its JavaScript updates or resource loading before the screenshot. Try a longer delay, use a selector for content that should be present, and inspect the result again. A delay cannot make inaccessible or failed resources load.
  • The capture has the wrong dimensions or cuts off content: Check vwidth and vheight, then decide whether viewport-only output or full-page capture is intended. A narrower viewport can trigger a different responsive layout.
  • The selector capture returns nothing useful: Confirm that the CSS selector matches the rendered page, not just the original source, and allow time for dynamically inserted content before capture.
  • A local page loses styling or images: Check that its relative asset paths still resolve from the HTML file’s location and that any required local files are present.
  • One URL fails in a batch: Run it on its own. This separates a page-specific load or rendering issue from problems with the other URLs or output paths.
  • Code copied from an older package version errors: Check the installed function’s help and package version. Function signatures, defaults, and browser discovery can depend on the installed package and system setup.

Performance, reliability, and cost considerations

Local browser-based capture avoids sending the work to a screenshot service, but it requires maintaining a compatible browser in the environment that runs R. The result can depend on browser version, viewport, page state, network availability, and the timing of the capture. If you need stable output, record those conditions alongside the code and review generated files when the page or browser changes.

For multiple URLs, parallel capture can reduce the time spent waiting on a batch, but the package documentation does not establish a general speed advantage or a success rate. Actual elapsed time depends on the pages and machine. Likewise, the available package references describe controls and supported inputs, not a controlled comparison of image fidelity or performance among webshot2, pagedown, and Chromote.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

These R packages are software rather than a reason to buy dedicated hardware. The practical prerequisite established for the browser-driven approaches is a suitable installed browser; whether a given server or computer can run it depends on that environment.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.