Use dom-to-image to render a DOM node into an image, then download or display the result. For a long page, select the document element and pass its scroll width and height as render dimensions. This is a practical starting point, not a guarantee: very large pages, missing cross-origin images, and browser rendering limits can produce incomplete output, so inspect the result in the browser you plan to support.
What dom-to-image captures—and what “full-page” means
dom-to-image is a JavaScript library that renders a selected DOM node to SVG, PNG, or JPEG. Its methods return promises, so you can wait for the generated image before displaying or downloading it.
This is DOM rendering, not a physical screenshot of the browser window. The output is derived from the node and the resources and styles the library can render. A page-sized image therefore depends on selecting a node that contains the page content and requesting dimensions that cover that content. It does not establish a universal maximum capture size or guarantee a pixel-perfect match to what you see on screen.
For the whole document, document.documentElement is a reasonable starting selection. Some sites place relevant content or scrolling on a different element, such as document.body or an application container. Check which element actually contains the content and has the expected scroll dimensions before capturing.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
- 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 the library and choose a node
Install from npm
In a project that uses npm, install the package:
npm install dom-to-image
In a bundled application, import the package and select the node you want to render. The repository also documents including a browser script that exposes a global domtoimage object; use the method names below with whichever setup you choose.
import domtoimage from 'dom-to-image';
const node = document.documentElement;
If your build setup does not accept a default import, follow the module format supported by your project and the package. The important part is that domtoimage refers to the library object and node is the DOM element to capture.
Capture the full document to a PNG file
This example requests the document element’s scroll dimensions, renders a PNG, and triggers a browser download:
const node = document.documentElement;
domtoimage.toPng(node, {
width: node.scrollWidth,
height: node.scrollHeight,
})
.then((dataUrl) => {
const link = document.createElement('a');
link.download = 'page.png';
link.href = dataUrl;
link.click();
})
.catch((error) => {
console.error('Could not render the page', error);
});
The width and height options are applied to the node before rendering. Reading scrollWidth and scrollHeight is useful for estimating the content extent, but this adaptation is not a project-published guarantee that every long page will render completely. Confirm the resulting file’s dimensions and inspect the bottom and edges for clipping or blank areas.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #2
- 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.
Capture a particular region instead
To capture a component rather than the whole page, pass that element as the node. For example:
const node = document.querySelector('#report');
if (!node) {
throw new Error('Could not find #report');
}
domtoimage.toPng(node)
.then((dataUrl) => {
const image = new Image();
image.src = dataUrl;
document.body.appendChild(image);
})
.catch((error) => console.error('Could not render #report', error));
Use a selector that uniquely identifies the intended element. If you need a long component’s full contents, measure that element’s own scroll dimensions rather than assuming the document’s dimensions apply.
Choose the output format and rendering options
The library provides several output methods. Pick the format according to how the image will be used:
| Method | Result | Useful when |
|---|---|---|
toPng(node, options) |
PNG data URL | You want a lossless raster image that can be shown in an <img> or downloaded. |
toJpeg(node, options) |
JPEG data URL | You prefer a compressed photographic image and do not need transparency. |
toBlob(node, options) |
Blob | You want a binary image object, for example to save or process it without first handling a data URL. |
toSvg(node, options) |
SVG data URL | You want the library’s SVG output rather than a raster format. |
toPixelData(node, options) |
Pixel data | You need pixel values for further processing rather than a ready-to-download image. |
These methods are asynchronous. Handle their returned promises with .then() and .catch(), or use async/await inside an error-handling block.
Rank #3
- 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.
Set a background, quality, or temporary style
bgcolorsets the background color for the rendered image. Set it when a transparent or unspecified background is not suitable for the destination.qualitycontrols JPEG image quality. It applies to JPEG output; it is not a way to increase the rendered dimensions.styleapplies style properties to the node before rendering. This can help adjust the captured node’s appearance for the image.filterexcludes a node and its children from rendering. Use it when a subtree should not appear in the result.imagePlaceholdersupplies fallback content if fetching an image fails. It can prevent a failed image resource from leaving an unintended gap, but it does not make the original resource available.
Options can be passed as the second argument to the output method. Keep changes targeted: a style or dimension adjustment that improves one page can change its layout, so inspect the output rather than assuming the rendered version matches the live page exactly.
Check dimensions and browser limits on long pages
Before treating an image as full-page, compare the captured bounds with the content you intended to include. Scroll dimensions are a useful input, not proof that the library can render a canvas of any resulting size. Long pages with large images or wide content can exceed browser or device rendering limits and may yield blank or partial output without an obvious error.
Browser canvas limits vary by browser and platform and can change. The html2canvas FAQ gives rough guidance for canvas limits in its own context, but those figures are not verified dom-to-image thresholds; do not use them as a promised maximum for this library. Test representative pages in the actual browsers and devices you support.
- Check that the selected element contains the entire region you want, including content below the initial viewport.
- Inspect the downloaded image’s width and height, then visually check its top, bottom, and side edges.
- Try a smaller node or a smaller capture region if output is blank, clipped, or incomplete.
- Test pages with their real fonts, images, and styles; resource availability and browser behavior affect the result.
Why the image may differ from the page
It is a rendered representation, not a guaranteed browser photograph
DOM-rendered image libraries reconstruct an image from page information rather than capturing the browser display as a camera would. CSS support can vary between tools, and a rendered result should not be described as guaranteed pixel-perfect. In particular, html2canvas documents that it reconstructs a representation from DOM information and implements CSS properties individually; that is a caution about html2canvas specifically, not a statement of dom-to-image’s exact compatibility.
Rank #4
- 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
Cross-origin images and unavailable resources
Images and other resources may fail to load into a render, including when browser origin rules prevent access. The library’s imagePlaceholder option can provide fallback content for an image fetch failure. Do not transfer settings from another library: for example, useCORS is documented as an html2canvas option, not a dom-to-image option.
Dynamic content and page state
The capture reflects the DOM and resources available when the rendering runs. If content is still loading or changing, wait until the page is in the state you want before calling the method. For pages whose content depends on application state, make sure the chosen node and its rendered dimensions correspond to that state.
Troubleshooting incomplete or failed captures
| Symptom | Likely cause | What to try |
|---|---|---|
| The output stops before the bottom of the page. | The selected node or requested height does not include the full content, or the render has hit a browser or device limit. | Check the selected element’s scrollHeight, pass the intended height, and test a smaller region if the image remains incomplete. |
| The image is blank or only partly drawn. | The requested image may be too large for the environment, or required resources may not have rendered successfully. | Reduce the captured area and inspect the page’s images and other resources. Test on the target browser and device. |
| One or more images are missing. | An image fetch failed or browser origin rules restricted access. | Check that the resource is available to the page and try imagePlaceholder when a fallback is acceptable. |
| The output looks different from the live page. | The image is a DOM-based rendering and may not reproduce every browser-rendered detail. | Check the specific styles and resources involved, then compare the result in each supported browser. |
| The promise rejects and the download never starts. | The node was invalid, rendering failed, or a resource or browser error interrupted the operation. | Confirm that the selector returned an element, inspect the caught error in the console, and test with a smaller or simpler node to isolate the cause. |
When to use a browser screenshot instead
dom-to-image is an in-page option when you need to render a DOM node from JavaScript. If your requirement is to capture a page in a real browser, control browser state outside the page, or run captures server-side, a browser automation approach may fit better. The html2canvas FAQ points to browser-native screenshot APIs as a more reliable path for browser extensions and to Puppeteer or Playwright for server-side screenshots; those are recommendations from html2canvas documentation, not compatibility guarantees for dom-to-image.
Choose based on where capture runs, how faithfully it needs to reflect browser state, how cross-origin resources are handled, and how your workflow will manage very long pages. Whichever approach you use, validate the result for the actual site and runtime rather than assuming that “full-page” means unlimited dimensions.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
- 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.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. For a one-request capture, replace the example URL with your target page and pass your API key:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request parameters and options. Its clean-shot steps can accept cookie or consent banners and remove known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides screenshot and page-information tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.
FAQ
Can dom-to-image save a PDF?
The documented output methods include SVG, PNG, JPEG, Blob, and pixel data; they do not establish a PDF output method. For PDF output, use a capture workflow that explicitly supports PDF.
Can I exclude a navigation bar from the image?
Yes. Use the documented filter option to exclude a node and its descendants, or select a narrower node if the navigation is outside the region you need.
Does full-page capture mean the browser will scroll and stitch screenshots?
Not in the method described here. This approach renders a selected DOM node and requests dimensions for it; it is not a sequence of viewport screenshots stitched together.
Quick Recap
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.

