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

Draw every inner canvas first, then wait for the renderer and at least one browser paint frame before calling html2canvas(). When the returned Promise resolves, export its canvas with toDataURL() or toBlob(). A blank nested region is usually a timing problem: html2canvas cloned the container before the chart, game, or custom renderer had finished putting pixels into the child canvas.

The reliable sequence

Keep the capture target on the element that contains the nested canvas. Your application—not html2canvas—must know when the inner renderer is complete.

  1. Start the chart, game, or custom draw operation.
  2. Await its completion Promise (or finish the synchronous draw).
  3. Wait for a browser frame so painting can catch up.
  4. Call html2canvas() on the containing element.
  5. Await the returned Promise.
  6. Export the resulting canvas.
async function captureContainer() {
  // Application code: resolve when the nested canvas contains its final pixels.
  await drawNestedCanvas();
  await new Promise(requestAnimationFrame);

  const output = await html2canvas(document.querySelector('#capture'), {
    useCORS: true,
    backgroundColor: null,
    scale: window.devicePixelRatio,
  });

  const pngUrl = output.toDataURL('image/png');
  return pngUrl;
}

drawNestedCanvas() is deliberately an application function. html2canvas cannot infer when Chart.js, a WebGL scene, a game loop, or another third-party renderer has completed. If drawing is synchronous, the animation-frame wait still gives the browser a chance to present the new pixels before the DOM is cloned.

What html2canvas captures—and what it does not

html2canvas does not ask the browser for a native screenshot. The project describes it as building a representation from DOM information, cloning and traversing the tree, then painting supported properties to an output canvas (project documentation). That reconstruction can differ from the visible screen when CSS, browser features, or content outside the accessible DOM is unsupported.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Wacom Intuos Small, Wired Graphic Drawing Tablet with Pen + Software
  • Wacom Intuos Small Graphics Drawing Tablet: Enjoy industry leading tablet performance in superior control and precision with Wacom's EMR, battery free technology that feels like pen on paper
  • Works With All Software: Wacom Intuos tablet can be used in any software program to explore new facets of digital creativity; draw, paint, edit photos/videos, create designs, and mark up documents
  • What the Professionals Use: Wacom's industry leading pen technology and pen to paper feeling makes it the preferred drawing tablet of professional graphic designers
  • Software and Training Included: Only Wacom gives you software with every purchase. Register your Intuos tablet and gain access to some of the best creative software and Wacom's online training
  • Wacom is the Global Leader in Drawing Tablet and Displays: For over 40 years in pen display and tablet market, you can trust that Wacom to help you bring your vision, ideas and creativity to life

A child <canvas> is therefore safest when it already contains its pixels before cloning begins. Capture the actual element that contains the canvas; a wrapper with different dimensions or an inaccessible frame document can produce a result that looks blank even though the live page looks correct.

Does html2canvas copy an existing canvas?

It can render an accessible canvas element as part of the reconstructed DOM, but it is not a general-purpose pixel copier for every browser boundary. The destination option named canvas only supplies an existing output canvas for html2canvas to draw into; it does not import a nested canvas automatically. Treat the child canvas as input that must be fully rendered and readable first.

A complete browser example

The following example draws a nested canvas, captures its parent, and downloads a PNG. Replace the drawing function with your own renderer or chart library’s completion hook.

<div id="capture">
  <h2>Revenue</h2>
  <canvas id="chart" width="900" height="450"></canvas>
</div>
<button id="save">Save PNG</button>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/html2canvas.min.js"></script>
<script>
const chart = document.querySelector('#chart');

function drawNestedCanvas() {
  const ctx = chart.getContext('2d');
  ctx.clearRect(0, 0, chart.width, chart.height);
  ctx.fillStyle = '#1769aa';
  ctx.fillRect(80, 80, 500, 180);
  ctx.fillStyle = '#111';
  ctx.font = '28px sans-serif';
  ctx.fillText('Quarterly revenue', 80,  fifty =  fifty =  fifty =  fifty =  fifty =  fifty = 50);
  return Promise.resolve();
}

async function captureContainer() {
  await drawNestedCanvas();
  await new Promise(requestAnimationFrame);
  const output = await html2canvas(document.querySelector('#capture'), {
    useCORS: true,
    backgroundColor: null,
    scale: window.devicePixelRatio,
  });
  return output;
}

document.querySelector('#save').addEventListener('click', async () => {
  const output = await captureContainer();
  const link = document.createElement('a');
  link.download = 'capture.png';
  link.href = output.toDataURL('image/png');
  link.click();
});
</script>

In production, correct the sample’s text baseline to your desired coordinate and use your real renderer. The important part is the ordering, not the chart geometry.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
XPPen Deco 01 V3 10x6 Drawing Tablet, 16K Battery-Free Stylus, 8 Keys
  • Word-first 16K Pressure Levels: The upgraded stylus features 16,384 levels of pressure sensitivity and supports up to 60 degrees of tilt, delivering smoother lines and shading for a natural drawing experience. With no battery or charging needed, it operates like a real pen, making it easy for beginners to create effortlessly. This functionality helps novice artists develop their skills and explore their creativity without the intimidation of complex tools
  • Designed for Beginners: This drawing pad desinged with 8 customizable shortcuts for both right and left-hand users, express keys create a highly ergonomic and convenient work platform
  • Perfectly Adapted for Android: The XPPen Deco 01 V3 art tablet supports connections with Android devices running version 10.0 and above. It is recommended to download the XPPen Tools Android application, which adapts to your smartphone's screen aspect ratio, ensuring accurate mapping. It also supports mapping on Android screens with different aspect ratios in portrait mode
  • Large Drawing Space, Bigger Bold Inspiration: This expansive drawing pad has10 x 6.25-inch helps you break through the limit between shortcut keys and drawing area
  • Easy Connectivity for Beginners: The Deco 01 V3 offers USB-C to USB-C connectivity, plus adapters for USB C. This ensures easy connection to various devices, allowing beginner artists to set up quickly and focus on their creativity without compatibility concerns. Whether using a laptop, tablet, or desktop, the Deco 01 V3 provides a seamless experience, making it an ideal choice for those just starting their digital art journey

Options that matter for nested canvases

scale: output sharpness

Set scale to window.devicePixelRatio for a high-DPI result, as shown in the official configuration examples (configuration). Larger values increase output dimensions and memory use; use a lower fixed value when screenshots are too large.

Cropping with x, y, width, and height

When only the chart area is needed, provide crop coordinates in the target element’s coordinate system. First make the complete content appear, then tune the crop. Cropping too early can hide the real timing or layout failure.

Cross-origin images: useCORS, proxy, and allowTaint

useCORS: true asks the browser to request images with CORS. It works only when the remote server returns permitting CORS headers. If direct loading is impossible, proxy can route resources through a proxy that your application controls. The html2canvas project states that images must be same-origin unless CORS or a proxy makes them available (FAQ).

allowTaint controls whether cross-origin images that would taint the output are allowed into rendering. It does not make a tainted canvas readable for a later toDataURL() call. If the nested canvas draws an image or video from another origin without successful CORS, redraw it from an accessible source or fix the response headers.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
HUION Inspiroy H640P 6x4 inch Drawing Tablet 8192 Pen Pressure
  • Customize Your Workflow: The 6 customizable press keys on Huion H640P drawing tablet for pc let you assign your most-used commands—like undo, zoom, brush switch, or save—so you can keep your hands on the tablet and your mind on the art. Whether you're a digital painter switching brushes, or a comic artist zooming in and out, these keys keep your workflow smooth and uninterrupted. Plus, the Huion driver lets you save different shortcut profiles for different apps, so you never have to reconfigure when switching software.
  • Professional Pen Performance: Huion H640P drawing pad for computer comes with the battery-free PW100 stylus that's always ready when inspiration strikes. With 8192 levels of pressure sensitivity, every light sketch, or bold stroke responds naturally to your hand—just like a real pen. The 5080 LPI resolution and 233 PPS report rate deliver lag-free, precise strokes, so you can draw confidently without second-guessing your cursor. The pen side buttons help you switch between pen and eraser instantly.
  • Compact and Portable: Huion H640P computer graphics tablet features a compact, ultra-portable design at just 0.3 inches thin and 0.61 lbs light, so it slides easily into your backpack—perfect for sketching in coffee shops, taking notes in class, or editing on the go between home and studio. The 6x4 inch active area offers enough room for natural pen movements while fitting comfortably on crowded desks, or lecture hall seats.
  • Stable Compatibility: Huion H640P graphic drawing tablet works seamlessly with Mac, Windows, Linux PCs, and Android smartphones/tablets (OS version 6.0 or later). Left-handed friendly, and you just need to flip the tablet and adjust the settings in the driver. Please note: H640P does NOT support iPhone/iPad.
  • Move Beyond the Mouse: Huion Inspiroy H640P is a pen tablet that replaces your mouse for more natural, precise control. Freehand draw, take notes, or even play OSU—everything you do with a mouse, you can do better with a pen. The precise tip makes it ideal for detailed photo editing, graphic design, or signing PDF. Meanwhile, the ergonomic pen grip helps you avoid the strain that comes from hours of using a mouse.

foreignObjectRendering

With foreignObjectRendering: true, html2canvas can use its alternate ForeignObjectRenderer where the browser supports it. This may improve fidelity for some DOM/CSS combinations, but it changes browser compatibility and is not a universal fix for a blank nested canvas. Try the default renderer first.

onclone and canvas

Use onclone to make capture-only changes in the cloned document—for example, reveal a print label without altering the live page. The canvas option supplies the destination canvas. Neither option replaces the need to finish the nested draw.

Charts, animation, WebGL, and asynchronous data

Chart libraries

Prefer the library’s documented “render complete” callback or Promise. Do not assume that the constructor returning means the final pixels are present; fonts, data, and animations may still be pending. Disable animation for deterministic exports when your library supports that setting, then await its completion callback.

Animations and games

Pause the loop at a known frame, draw that frame, resolve your capture Promise, and resume afterward. Capturing during a continuously changing animation can produce a valid but inconsistent frame.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
4 Pack LCD Writing Tablet for Kids, 8.5 Inch Colorful Doodle Board Drawing Tablet, Educational Learning Toys Birthday Gifts for Boys Girls Age 3 4 5 6 7 8
  • 4 Pack for More Fun: Apply the newest flexible liquid crystal technology, brighter and clearer than most LCD writing tablet. Take pressure-sensitive technology, you can draw lines of different thicknesses through different pressure levels. Package includes 4 pack lcd writing tablet (Blue, Light blue, Green and Pink), free children's imagination and creativity.
  • 8.5 Inch Colorful Lcd writing Tablet: TQU kids LCD doodle board is a creative education and learning toy, perfect support for drawing, writing, spelling, math, remark, and notes which can let your kids freely release their natural instincts. With erase button on the front and lock switch. You can draw and erase easily by pressing the button on the front of the board. The pen fits snug on top of tablet and it will not come loose.
  • Easy to use and Durable: The LCD writing tablet for kids is easy to use, just use the stylus to write, draw, scribble, doodle anything you want. Press the erase button to clear the screen in one second. Or press the lock key to save the screen contents. Our magic reusable drawing tablet is built in a button battery.
  • Safe & Portable Toddler Travel Toys: Great for quiet, take-along entertainment. It’s an easy way to color on the go without lugging a bunch of stuff in the car or to a restaurant or church.
  • Perfect Gift Idea: The multi-functional LCD writing tablet is a great gift choice for kids. It can be an educational toy for preschoolers. A perfect parent-pick gift for 3 4 5 6 7 8 year old girls and boys on back to school, homeschool, birthday, Easter, Children's Day, Thanksgiving Day, Christmas and any occasion.

WebGL canvases

Finish GPU commands and present the intended frame before capture. A security or context configuration that prevents reading pixels cannot be repaired by html2canvas; use an application-supported export path or render the scene in a readable canvas.

Same-origin rules, tainting, and iframes

Once a canvas has been tainted by a cross-origin image or video, browser security prevents safe pixel reads. html2canvas reports the same limitation: an already tainted canvas cannot be read by the script (documentation). CORS must be valid at the time the resource is loaded; adding useCORS after the fact does not clean existing pixels.

Same-origin iframe

A same-origin iframe can be rendered recursively because the parent can access its document.

Cross-origin or sandboxed iframe

Cross-origin frames, and sandboxed frames without allow-same-origin, are blocked by browser security. The outer page cannot inspect their contentDocument. Run html2canvas inside the frame with cooperation from that document, or redesign the integration so the content is available to the capturing origin. A parent-page option cannot bypass this boundary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
XPPen Artist 13.3 Pro V2 Drawing Tablet with Screen, 16K, Full-Laminated
  • PLEASE NOTE:XPPen Artist13.3 Pro drawing tablet Need to connect with computer,you need to use it with your computer or laptop, the 3 in 1 cable is included
  • Drawing Tablet with Screen: Tilt Function- XPPen Artist 13.3 Pro supports up to 60 degrees of tilt function, so now you don't need to adjust the brush direction in the software again and again. Simply tilt to add shading to your creation and enjoy smoother and more natural transitions between lines and strokes
  • Graphics Tablets: High Color Gamut- The 13.3 inch fully-laminated FHD Display pairs a superb color accuracy of 88% NTSC (Adobe RGB≧91%,sRGB≧123%) with a 178-degree viewing angle and delivers rich colors, vivid images, and dazzling details in a wider view. Your creative world is now as powerful as it is colorful
  • Drawing Pad: One is enough- The sleek Red Dial on the display is expertly designed with creators in mind, its strategic placement allows for natural drawing postures. With just one wheel, you can effortlessly zoom in and out, adjust brush sizes, and flip the canvas—all tailored to suit the habits of everyday artists. The 8 customizable shortcut keys allow you to personalize your setup, streamlining your workflow and enhancing creative efficiency
  • Universal Compatibility & Software Support:supports Windows 7 (or later), Mac OS X 10.10 (or later), Chrome OS 88 (or later), and Linux systems. Fully compatible with major creative software including Photoshop, Illustrator, SAI, and Blender 3D. Register your device to access additional programs like ArtRage 5 and openCanvas for expanded creative possibilities.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Debugging a blank nested region

  1. Inspect the inner canvas. Confirm its width and height are non-zero and that it contains pixels before capture. A quick test is to call innerCanvas.toDataURL() before html2canvas; a security exception indicates tainting.
  2. Verify the target. Pass the element that actually contains the canvas, not an ancestor with hidden dimensions and not an inaccessible frame document.
  3. Prove sequencing. Log immediately before and after the draw Promise, then await requestAnimationFrame before html2canvas.
  4. Enable logging. html2canvas logging is enabled by default; inspect the browser console while reproducing the issue (configuration).
  5. Read security errors. Fix image or video origins, response headers, or proxy configuration before changing rendering options.
  6. Compare renderers. Test the default renderer first; compare foreignObjectRendering: true only in a browser combination where it is supported.
  7. Tune geometry last. After content appears, adjust scale and crop coordinates.
  8. Export after resolution. Never call toDataURL() on the Promise returned by html2canvas; await it first.

Common errors and fixes

Symptom Likely cause Fix
Child canvas is white or transparent Capture ran before drawing completed Await the renderer, then wait one animation frame.
SecurityError from toDataURL() The canvas is tainted by a cross-origin resource Use same-origin assets or valid CORS/proxy support; redraw after fixing access.
Images missing but DOM text appears Remote image lacks CORS headers or loaded after cloning Preload it, enable useCORS when permitted, or configure a proxy.
Iframe content missing Cross-origin or sandbox isolation Capture inside the frame or obtain cooperation from its origin.
Screenshot is sharp but enormous Device-pixel scale multiplies dimensions Use a controlled numeric scale and crop with width/height.
Layout differs from the screen DOM reconstruction does not support a CSS feature exactly Adjust capture-only markup in onclone, or use a native browser capture.

When html2canvas is the right tool

Use it when the target DOM, nested canvas, and image resources are accessible to the page and you want a client-side image. It gives direct control over crop geometry, output scale, and a capture-only clone. Choose native browser automation or server-side rendering when you need a pixel-level browser screenshot, must capture cross-origin frames without cooperation, or cannot change inaccessible resources.

Evaluate alternatives on five questions: can the renderer read the content; how closely must CSS match; does the inner renderer expose a completion signal; what output dimensions are required; and can any iframe origin cooperate? These constraints determine the tool more than a single option flag.

Or skip the browser setup

For a server-side screenshot or PDF, ScreenshotNeo accepts one GET request and returns PNG, JPEG, WebP, or PDF. It removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, with the result identified by X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools to Claude, Cursor, and other MCP clients.

Basic cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const data = Buffer.from(await res.arrayBuffer());
require('node:fs').writeFileSync('shot.webp', data);

See the full parameter list and options in the ScreenshotNeo documentation. You can select full-page or element captures, dark mode, device presets, retina scale, custom CSS and JavaScript, waits, request blocking, headers, cookies, geolocation, transparent backgrounds, resizing, caching, signed links, asynchronous webhooks, bulk capture, and PDF settings. Every plan includes every feature. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

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

Frequently Asked Questions

Can I capture only the nested canvas instead of its parent?

Yes. Pass the canvas element itself to html2canvas when you do not need surrounding DOM, but the same draw-completion, accessibility, and tainting rules still apply.

Why does waiting with setTimeout sometimes help but remain unreliable?

A fixed delay guesses at renderer timing. A completion Promise or callback identifies the actual end of drawing; use a frame wait afterward only to coordinate browser painting.

Will html2canvas capture a cross-origin iframe if the page has CORS enabled?

No. Image CORS and iframe document access are separate controls. The frame must be same-origin or cooperate by running capture inside itself.

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.

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.