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

Capture both elements, wait for the two promises to resolve, then draw the resulting canvases onto a newly sized destination canvas with Canvas 2D drawImage(). For a vertical result, use the wider source width and the sum of both heights; for a side-by-side result, use the sum of widths and the taller source height.

The basic composition pattern

html2canvas() is asynchronous. Each call returns a Promise that resolves to a <canvas> element, so composition must happen after both captures finish. Promise.all() starts independent captures together and gives you both results in their original order.

const [first, second] = await Promise.all([
  html2canvas(document.querySelector('#first')),
  html2canvas(document.querySelector('#second')),
]);

const combined = document.createElement('canvas');
combined.width = Math.max(first.width, second.width);
combined.height = first.height + second.height;

const context = combined.getContext('2d');
context.drawImage(first, 0, 0);
context.drawImage(second, 0, first.height);

document.body.appendChild(combined);

The first image is placed at the destination origin. The second starts at a y-coordinate equal to the first bitmap’s height, so it cannot overlap it. The calculation uses canvas.width and canvas.height, not CSS dimensions.

Complete browser example

This page contains two capture targets, a button, and a PNG download. Load html2canvas before the application script, or install it through your normal package workflow.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Dell Optiplex 7050 SFF Desktop PC Intel i7-7700 4-Cores 3.60GHz 32GB DDR4 1TB SSD WiFi BT HDMI Duel Monitor Support Windows 11 Pro Excellent Condition(Renewed)
  • Model: Dell OptiPlex 7050 Small Form Factor (SFF)
  • Processor: Intel Core i7-7700 3.60 GHz
  • Memory: 32GB DDR4 Ram
  • Storage: 1TB Solid State Drive (SSD) Fast Boot + Storage
  • Operating System: Windows 11 Pro (64-bit)
<button id="capture" type="button">Combine captures</button>
<div id="first" class="panel">
  <h2>First panel</h2>
  <p>This content becomes the top part of the output.</p>
</div>
<div id="second" class="panel">
  <h2>Second panel</h2>
  <p>This content becomes the lower part of the output.</p>
</div>
<img id="preview" alt="Combined capture preview" hidden>

<script src="https://cdn.jsdelivr.net/npm/html2canvas@latest/dist/html2canvas.min.js"></script>
<script>
const button = document.querySelector('#capture');
const preview = document.querySelector('#preview');

button.addEventListener('click', async () => {
  button.disabled = true;
  try {
    const [first, second] = await Promise.all([
      html2canvas(document.querySelector('#first')),
      html2canvas(document.querySelector('#second')),
    ]);

    const combined = document.createElement('canvas');
    combined.width = Math.max(first.width, second.width);
    combined.height = first.height + second.height;

    const context = combined.getContext('2d');
    if (!context) throw new Error('Canvas 2D context is unavailable');
    context.drawImage(first, 0, 0);
    context.drawImage(second, 0, first.height);

    preview.src = combined.toDataURL('image/png');
    preview.hidden = false;

    combined.toBlob((blob) => {
      if (!blob) throw new Error('PNG encoding failed');
      const link = document.createElement('a');
      link.href = URL.createObjectURL(blob);
      link.download = 'combined-capture.png';
      link.click();
      URL.revokeObjectURL(link.href);
    }, 'image/png');
  } catch (error) {
    console.error('Capture failed:', error);
    alert('The captures could not be combined. Check the console for details.');
  } finally {
    button.disabled = false;
  }
});
</script>

For production code, prefer toBlob() for downloads and uploads. toDataURL() is convenient for a small preview but stores the entire encoded image in a JavaScript string and can consume considerably more memory.

Choose the output layout

Vertical stacking

Use this for a long report, receipt, or page assembled from sections. The destination width is the larger source width and the destination height is the sum of both heights.

const gap = 24;
combined.width = Math.max(first.width, second.width);
combined.height = first.height + gap + second.height;
context.fillStyle = '#ffffff';
context.fillRect(0, 0, combined.width, combined.height);
context.drawImage(first, 0, 0);
context.drawImage(second, 0, first.height + gap);

The background fill is important when you want a predictable color instead of transparent gaps.

Side-by-side placement

For a comparison image, add the source widths and use the taller source height. The second bitmap begins at the first bitmap’s width.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const combined = document.createElement('canvas');
combined.width = first.width + second.width;
combined.height = Math.max(first.height, second.height);

const context = combined.getContext('2d');
context.drawImage(first, 0, 0);
context.drawImage(second, first.width, 0);

If the panels have different heights, the shorter one leaves transparent pixels below it unless you paint a background first.

Rank #2
Apple 2026 MacBook Neo 13-inch Laptop with A18 Pro chip: Built for AI and Apple Intelligence, Liquid Retina Display, 8GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera; Blush
  • AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
  • FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
  • FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
  • UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
  • A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.

Overlap or layered composition

Set the destination dimensions for the design, draw the background or lower layer first, and then draw the foreground. Later calls are painted above earlier pixels.

combined.width = 1200;
combined.height = 800;
context.fillStyle = '#111827';
context.fillRect(0, 0, combined.width, combined.height);
context.drawImage(first, 40, 40, 700, 500);
context.drawImage(second, 360, 220, 700, 500);

The four-argument form of drawImage() deliberately resizes a source. Use it only when the design calls for resampling; otherwise, draw at native bitmap dimensions.

Resolution, scale, and coordinate choices

html2canvas defaults its scale option to window.devicePixelRatio. A high-density display can therefore produce a bitmap several times larger than the element’s CSS box. That is why a 600 CSS-pixel element may have a canvas width of 1,200 or more.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Preserve capture resolution: calculate positions and output dimensions from each source’s width and height. This avoids accidental resampling.
  • Create a CSS-sized result: choose one scale, divide or resize source dimensions consistently, and use matching destination coordinates. Mixing CSS pixels with bitmap pixels causes gaps, cropping, or unexpected size.
  • Control scale at capture time: pass an explicit scale to both html2canvas calls when predictable output size matters. Use the same value unless different resolutions are intentional.

Keep the destination dimensions as integers. Before allocating a very large canvas, estimate memory: an RGBA bitmap requires roughly four bytes per pixel, before temporary buffers and encoded output are included.

Capture in parallel or sequentially?

Parallel captures with Promise.all()

Parallel scheduling is concise and normally reduces total waiting time when the targets are independent. Both render operations and their temporary bitmaps exist at once, so peak memory is higher.

Rank #3
Sale
HP Essential 2026 Laptop Student Business, Ultra Light, 4GB RAM, Intel CPU
  • Performance: Powered by Intel Celeron N4500 dual-core processor with up to 2.8 GHz burst frequency and 4MB L3 cache, this HP Chromebook delivers smooth multitasking for everyday computing. With 4GB LPDDR4x-2933 RAM and Intel UHD Graphics, enjoy seamless web browsing, video streaming, and productivity apps. Chrome OS boots in seconds and updates automatically, keeping your laptop secure and running at peak performance for students, professionals, and home users.
  • Immersive 14-Inch HD Display: Experience clear, vibrant visuals on the 14-inch diagonal HD (1366 x 768) anti-glare display with 250 nits brightness and 62.5% sRGB color accuracy. The micro-edge design maximizes your viewing area with an impressive 80% screen-to-body ratio, perfect for streaming movies, video calls, and document editing. The anti-glare coating reduces eye strain during extended use, making it ideal for all-day productivity and entertainment in any lighting condition.
  • Advanced Connectivity & Ports: Stay connected with Wi-Fi 6 (2x2) for faster wireless speeds and Bluetooth 5.3 for seamless device pairing. Equipped with versatile ports including 1 USB Type-C 10Gbps (with USB Power Delivery and DisplayPort 1.4), 2 USB Type-A 5Gbps ports, 1 HDMI 1.4b, and 1 headphone/microphone combo jack. Connect external monitors, transfer files quickly, charge your device, and expand your workspace effortlessly for maximum productivity and flexibility.
  • All-Day Battery & Premium Design: The battery keeps you powered throughout your day, while the included 45W USB Type-C power adapter ensures fast charging. Featuring a sleek modern grey finish with vertical brushing pattern on the keyboard deck, this lightweight 3.35 lb Chromebook combines style and portability. The full-size modern grey keyboard and HP Imagepad provide comfortable typing and precise navigation for work, school, or entertainment on the go.
  • Enhanced Security & Multimedia: Built-in H1 secure microcontroller protects your data and privacy with enterprise-grade security. The HP True Vision 720p HD camera with integrated dual array digital microphones delivers crystal-clear video calls and online meetings. HD Audio with stereo speakers provides rich, immersive sound for music, videos, and calls. With 64GB eMMC storage, you have ample space for essential files while Chrome OS seamlessly integrates with Google Drive for cloud storage.

Sequential captures

const first = await html2canvas(document.querySelector('#first'));
// Release or process first here if your application needs to limit memory.
const second = await html2canvas(document.querySelector('#second'));

Use sequential work when the page is memory-constrained, when the second target depends on state established by the first, or when you intentionally want to limit rendering load. It increases elapsed time.

Export and lifecycle management

  • PNG: lossless and supports transparency; use combined.toBlob(callback, 'image/png').
  • JPEG: smaller for photographic content, but transparency is discarded; pass a quality value such as 0.9.
  • WebP: available in browsers that support that encoder; verify support if files are user-critical.

Revoke every object URL after the download or image has loaded. Remove references to source and destination canvases when finished so garbage collection can reclaim their backing stores. If you repeatedly capture, reuse a destination canvas only when its dimensions and background policy are known; otherwise, stale pixels can remain.

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.

Cross-origin images and tainted canvases

html2canvas follows browser security rules. A remote image, font, video frame, or other resource without appropriate CORS permission can taint a source canvas. Drawing that source into a new canvas does not remove the taint; export methods such as toBlob() and toDataURL() can then throw a security error.

Practical remedies

  • Serve the resource from the same origin as the page.
  • Configure the remote server to send an appropriate Access-Control-Allow-Origin header and use html2canvas with useCORS: true.
  • Route the asset through a server-side, same-origin proxy that you control.

allowTaint does not make a tainted canvas safe to read or export. It changes rendering behavior, not the browser’s origin-clean requirement.

Canvas size and browser limits

Maximum canvas dimensions vary by browser, operating system, graphics stack, and device. Oversized canvases may be blank, partially rendered, or fail without a useful exception. The limits documented by html2canvas are approximate guides, not guarantees.

Rank #4
Dell Optiplex 3060 Desktop Computer | Intel i5-8500 (3.2) | 32GB DDR4 RAM | 1TB SSD Solid State | Built in WiFi | Bluetooth | Windows 11 Professional | Home or Office PC (Renewed)
  • [INTEL POWERED CONTENT] - Built with a 8th Generation Hexa-Core Intel i5 and 32GB of DDR4 RAM; Modern, Windows 11 ready, with 4K support, Executive multitasking, media streaming and smooth, multi-tab web browsing; Perfect as an all-purpose multimedia computer; built for content creators; Plenty of RAM and Mass storage for photo and video editing powered by Intel HD 630
  • [LATEST WIRELESS TECH] - This Dell Desktop Computer easily connects to the internet through the Built In WiFi / Bluetooth
  • [SOLID STATE STORAGE] - This Dell Computer setup comes with an ultra-fast 1TB Solid State Drive (SSD); Setup as the primary boot device; Boot and load programs with lightning speed ; Additional expansion available
  • [BUY & OWN WITH CONFIDENCE] - From the world's largest Microsoft Authorized Refurbisher; Quality Guarantee and Free Tech Support; Award-winning Customer Service; | Support Sustainable Business
  • [MODERN HI-SPEED PORTS] - USB 3.0 (x4) | USB 2.0 (x4) | DisplayPort (x1) | HDMI Port (x1) | Audio Combo Jack (x1) | Audio Out (x1) | RJ-45 Ethernet (x1) | Internal SATA (x3)
  • Test the actual output size on the browsers and devices you support.
  • Split a long page into several captures instead of creating one enormous bitmap.
  • Reduce html2canvas scale or resize each source before composition when full device-pixel resolution is unnecessary.
  • Check for a zero-sized target before capture; hidden elements and collapsed containers can produce empty results.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failures

The second image is missing or appears at the wrong location

Check that the y-coordinate is first.height for vertical stacking, or the x-coordinate is first.width for side-by-side output. Do not use offsetHeight or CSS width when the source bitmap has a device-pixel scale.

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

The result is blank

Confirm that both selectors resolve to visible, laid-out elements and that the destination dimensions are positive. A destination that exceeds a device’s canvas limit can also render blank. Try a lower explicit capture scale and a smaller test region.

toDataURL() throws a security error

A source is probably tainted by cross-origin content. Apply the CORS or same-origin remedies above, then capture again; compositing an already tainted canvas cannot repair it.

Text or CSS differs from the page

html2canvas is a DOM renderer, not a native browser screenshot API. It reconstructs the image from DOM and style information and does not implement every CSS property. Verify each source capture independently before debugging the composition code.

Images are missing inside a capture

Wait until images and fonts are loaded before calling html2canvas, and ensure remote assets permit CORS when they are not same-origin. Lazy content may also need to be made visible or loaded before capture.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Dell OptiPlex Computer Desktop PC, Intel Core i5 3rd Gen 3.2 GHz, 16GB RAM, 2TB HDD, New 22 Inch LED Monitor, RGB Keyboard and Mouse, WiFi, Windows 11 Pro (Renewed)
  • 🖥POWERFUL PROCESSOR and SUPERIOR STORAGE: Configured with top of the Intel Core i5 processor for lightning-fast, reliable and consistent performance to ensure an exceptional PC experience. 16GB RAM memory to smoothly run multiple applications and browser tabs all at once. 2TB HDD storage space to store apps, games, photos, music, and movies. Loaded with 16GB to zip through multiple tasks in a hurry without lag.
  • 🖥️New 22 Inch Full HD (1920x1080) LED monitor: with 75hz, High-Quality panel with quick refresh rate and response time. With 1080p resolution, you can enjoy gaming or a modern computing experience. 22 Inch monitor has a Smart Contrast to provide optimized image quality. Bezel-less and sleek design with glossy finish, crisp edge-to-edge visuals. Wide Viewing Angles for clarity from any viewpoint. VESA Mountable and built-in tilt options allow for a variety of monitor configurations.
  • ⌨️ +🖱️ RGB KEYBOARD AND MOUSE | RGB SPEAKER: 3 LED Colors - Blue, red, green, Backlight LED Lights for use at night time, looks amazing. The keyboard mouse and speaker are responsive, reliable, and probably plastered in RGB lights. It's important you pick the right one for your desktop.
  • 💿 WINDOWS 10 Pro LATEST: A new installation of the latest Microsoft Windows 11 Professional 64 Bit Operating System software, free of bloatware commonly installed from other manufacturers. As Microsoft's latest and best OS to date, Windows 10 Pro 64 Bit will maximize the utility of each PC for years to come. Optional software such as Anti-Virus and Office 365 can also be easily downloaded through the Microsoft Windows App Store.

The browser becomes unresponsive

Reduce concurrent work by capturing sequentially, lower the scale, capture smaller elements, and avoid holding multiple large data URLs. Prefer blobs and release object URLs promptly.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server when you need a rendered URL rather than a DOM-only browser script. A single request returns PNG, JPEG, WebP, or PDF. It accepts cookie and consent banners like a visitor, then removes more than 60 known consent platforms along with newsletter popups and chat widgets before capture. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result.

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(`Screenshot failed: ${res.status}`);
const data = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', data));

See the ScreenshotNeo documentation for parameters and response headers. The service also supports full-page captures with lazy images loaded, CSS-selector element capture, dark mode, device presets or custom viewports, retina scale, PDF paper and page options, custom CSS and JavaScript, clicks, selector or network-idle waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, configurable caching, signed image links, asynchronous webhooks, up to 100 URLs per bulk call, a usage API, an OpenAPI specification, and familiar parameter names for easier migration. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

Plan Included shots Price
Free 1,000 per month $0, no card
Starter 3,000 $5
Growth 15,000 $15
Pro 60,000 $39
Scale 250,000 $99
Business 1,000,000 $249

Yearly billing gives two months free, and every feature is available on every plan. Start with 1,000 free screenshots a month with no card.

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.

Frequently Asked Questions

Can I combine more than two html2canvas results?

Yes. Allocate a destination large enough for the chosen layout and call drawImage() once for each source, updating each x and y offset as you place it.

Why are my source canvases different sizes on the same page?

html2canvas can follow the display’s device-pixel ratio, and the elements may also have different CSS dimensions. Inspect each bitmap’s width and height before calculating the destination.

Should I use an image editor instead of a canvas?

Canvas is appropriate for a browser-side result that you can immediately display, download, or upload. Use a server-side image pipeline when files are extremely large or must be processed reliably outside a browser.

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.

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