Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
HTML to PDF

How to Print a Full-Screen Web Page to a Multi-Page PDF with jsPDF and html2canvas

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

To print an entire HTML page with jsPDF and html2canvas, render the page element at its full scroll size, scale the canvas to the PDF page width, then slice the resulting image across multiple PDF pages. Setting windowWidth and windowHeight to the element’s scroll dimensions prevents the usual bottom clipping. The complete implementation below also handles margins, long documents, cross-origin images, and page slicing.

What this method actually does

html2canvas rebuilds the selected DOM in a canvas in the browser; it is not a native browser screenshot engine. Unsupported CSS can therefore look different from the live page. Its documentation describes the result as a screenshot based on the DOM, “not 100% accurate to the real representation.” The canvas is then passed to jsPDF.addImage(), which places it at coordinates and dimensions measured in the PDF’s units.

This produces a visual PDF. Text in the captured page is generally part of the image rather than selectable PDF text. If selectable text, semantic headings, links, and print-specific CSS are more important than a pixel-like snapshot, the browser’s native print dialog is often a better fit.

Prerequisites and a suitable capture target

  • A browser page containing the content you want to export.
  • html2canvas and jspdf installed in your JavaScript project.
  • A dedicated container is preferable to document.documentElement: it avoids capturing browser-only UI, sticky navigation, and unrelated widgets.
  • Images must be same-origin or served with CORS headers. Cross-origin iframes cannot be read because browser security blocks access to their content documents.

Install the libraries with your project’s package manager, for example:

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.
#1 Best Overall
Epson EcoTank ET-2800 Wireless Color All-in-One Supertank Printer - Black
  • INNOVATIVE CARTRIDGE-FREE PRINTING — No more dealing with lots of tiny ink cartridges; With this wireless document and photo printer each ink bottle set is equivalent to about 90 individual cartridges²
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; When you choose this combination printer, scanner and copier you can print up to 4,500 pages black/7,500 color³
  • COLOR PRINTING — Up to 2 years of ink in the box4 (and with every replacement ink set) for fewer out-of-ink frustrations
  • ZERO CARTRIDGE WASTE — By using an Epson EcoTank printer you can help reduce the amount of cartridge waste ending up in landfills
  • HOME PRINTER DESIGNED FOR RELIABILITY — The Epson EcoTank ET-2800 All-in-One Supertank Color Printer creates vivid, detailed prints and documents thanks to Micro Piezo Heat-Free Technology; Fire off 10 ISO pages per minute1 to easily finish large jobs
npm install html2canvas jspdf

Give the content a stable background and width before capturing. Hide controls that should not appear with a capture-only class, and expand accordions or lazy sections that must be included.

Basic full-page capture

The following module captures a container at its full scroll dimensions and puts the complete image on one PDF page. It is useful for short pages; a pagination-safe version follows.

import html2canvas from "html2canvas";
import { jsPDF } from "jspdf";

const element = document.querySelector("#print-area");
if (!element) throw new Error("#print-area was not found");

const canvas = await html2canvas(element, {
  windowWidth: element.scrollWidth,
  windowHeight: element.scrollHeight,
  scale: window.devicePixelRatio,
  useCORS: true,
  backgroundColor: "#ffffff"
});

const pdf = new jsPDF({ orientation: "p", unit: "pt", format: "a4" });
const pageWidth = pdf.internal.pageSize.getWidth();
const imageHeight = canvas.height * pageWidth / canvas.width;
pdf.addImage(canvas, "PNG", 0, 0, pageWidth, imageHeight);
pdf.save("full-page.pdf");

The aspect-ratio calculation is essential: imageHeight = canvas.height * pageWidth / canvas.width. Using an arbitrary height stretches or squashes the page.

Correct pagination for long pages

An A4 page has finite height. Adding a very tall image at y = 0 does not create extra pages; the lower part simply falls outside the page. Slice the canvas into page-sized sections instead. This implementation keeps a 36-point margin on every side and creates a new page for each slice.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import html2canvas from "html2canvas";
import { jsPDF } from "jspdf";

export async function printFullPagePdf({
  selector = "#print-area",
  fileName = "full-page.pdf"
} = {}) {
  const element = document.querySelector(selector);
  if (!element) throw new Error(`Element ${selector} was not found`);

  // Ensure lazy content and fonts have finished before rendering.
  if (document.fonts?.ready) await document.fonts.ready;
  const images = [...element.querySelectorAll("img")];
  await Promise.all(images.map(img => img.decode?.().catch(() => undefined)));

  const canvas = await html2canvas(element, {
    windowWidth: element.scrollWidth,
    windowHeight: element.scrollHeight,
    scale: Math.min(window.devicePixelRatio || 1, 2),
    useCORS: true,
    backgroundColor: "#ffffff",
    // Keep fixed-position site chrome from being mistaken for document content.
    scrollX: 0,
    scrollY: 0
  });

  const pdf = new jsPDF({ orientation: "p", unit: "pt", format: "a4" });
  const margin = 36;
  const pageWidth = pdf.internal.pageSize.getWidth();
  const pageHeight = pdf.internal.pageSize.getHeight();
  const usableWidth = pageWidth - margin * 2;
  const usableHeight = pageHeight - margin * 2;

  // PDF points per source pixel after fitting the canvas to usableWidth.
  const pointsPerPixel = usableWidth / canvas.width;
  const sliceHeightPx = Math.floor(usableHeight / pointsPerPixel);
  let sourceY = 0;
  let pageNumber = 0;

  while (sourceY < canvas.height) {
    const currentSliceHeight = Math.min(sliceHeightPx, canvas.height - sourceY);
    const slice = document.createElement("canvas");
    slice.width = canvas.width;
    slice.height = currentSliceHeight;
    const context = slice.getContext("2d");
    context.drawImage(
      canvas,
      0, sourceY, canvas.width, currentSliceHeight,
      0, 0, canvas.width, currentSliceHeight
    );

    if (pageNumber > 0) pdf.addPage();
    const renderedHeight = currentSliceHeight * pointsPerPixel;
    pdf.addImage(slice, "PNG", margin, margin, usableWidth, renderedHeight);
    sourceY += currentSliceHeight;
    pageNumber += 1;
  }

  pdf.save(fileName);
}

// Example button handler:
document.querySelector("#download-pdf").addEventListener("click", () =>
  printFullPagePdf({ selector: "#print-area", fileName: "article.pdf" })
);

Why the scroll dimensions matter

Viewport dimensions describe only what is currently visible. element.scrollWidth and element.scrollHeight describe the complete laid-out content. Passing them as windowWidth and windowHeight gives html2canvas a rendering area large enough for the full page. This is the primary fix for PDFs that stop at the viewport or omit the bottom of a document.

Rank #2
Sale
Epson EcoTank Photo ET-8550 Wireless Wide-Format All-in-One Tank Printer
  • CARTRIDGE-FREE PRINTING — Print lab-quality photos, graphics and creative projects; Get vibrant colors and sharp text with Epson's high-accuracy printhead and Claria ET Premium 6-color inks
  • INK BOTTLES — Save on photos1 and creative projects with affordable in-house printing; All-in-one printer allows you to print 4" x 6" photos for about 4 cents each vs. 40 cents with traditional ink cartridges1
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; Printer, scanner and copier lets you print up to 6,200 color pages³
  • PRINT FOR LONGER — Up to 2 years of ink in the box² (and with every replacement ink set) for fewer out-of-ink frustrations with this wireless printer
  • ZERO CARTRIDGE WASTE — Epson EcoTank printer helps reduce the amount of cartridge waste ending up in landfills; Cartridge-free printer uses high-yield ink bottles; Each replacement ink bottle set is equivalent to about 100 individual ink cartridges⁴

Choosing a scale

window.devicePixelRatio improves sharpness on high-density displays, but it multiplies memory use. The example caps it at 2 to reduce the risk of “canvas too large” failures. For very long pages, use a dedicated print container, lower the scale to 1, or capture sections separately.

Margins, orientation, and page breaks

Change format: "a4" to another jsPDF format, or use orientation: "l" for landscape. The slicing calculation must always use the actual page dimensions returned by pdf.internal.pageSize; never hard-code A4 measurements when allowing other formats.

Image slicing can cut a paragraph or card in half. If clean semantic breaks matter, split the HTML into page-sized sections before capture, or capture each section independently and add it to its own PDF page. That approach requires more layout work but avoids splitting important components.

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

Using html2pdf.js instead

html2pdf.js wraps html2canvas and jsPDF in one configuration object. It supports margins, image type and quality, html2canvas settings, jsPDF settings, and page-break modes. It is convenient for common exports; direct html2canvas plus jsPDF gives finer control over slicing, custom pagination, and recovery from unusually tall content.

Images, fonts, iframes, and other browser limits

Cross-origin images

A cross-origin image can taint the canvas, preventing it from being exported. useCORS: true works only when the image server sends an appropriate Access-Control-Allow-Origin header. Otherwise configure a same-origin proxy, self-host the asset, or omit it. Setting useCORS does not bypass server policy.

Rank #3
HP Smart Tank 5000 Wireless All-in-One Ink Tank Printer, Scanner, Copier with 2 Years of Ink Included, Best-for-Home, Cartridge-Free, Refillable and AI-Enabled. (5D1B6A)
  • SET IT UP ONCE AND PRINT WITH CONFIDENCE. No complicated maintenance. Just easy, reliable printing you can count on.
  • INK FOR YEARS. NOT MONTHS. Up to 2 years of ink included. Get thousands of pages of cartridge-free printing. More pages, less hassle
  • KEEPS PRINTING WELL AFTER COMPETITORS HAVE QUIT. No complex maintenance. Sharper text, richer colors.[2] Only with HP Smart Tank
  • PREMIUM SUPPORT - Strong technical expertise to solve issues faster
  • THE LAST PRINTER YOU'LL EVER NEED. Enjoy years of refillable, cartridge-free printing.

Cross-origin iframes

html2canvas cannot render the content document of a cross-origin iframe. Capture a same-origin iframe from its own document, replace the embedded content with an image, or use a server-side/browser automation screenshot service.

Lazy loading and dynamic content

Scroll through or otherwise initialize lazy sections before calling html2canvas. Wait for network requests, images, and web fonts. A page that is still changing can produce missing images, fallback fonts, or different heights between measurement and capture.

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

CSS fidelity

Because the library reconstructs the DOM, browser effects and unsupported CSS may differ. Test gradients, filters, transforms, sticky elements, pseudo-elements, animations, and complex blend modes. Disable animations during capture to prevent inconsistent frames.

Troubleshooting a cut-off or broken PDF

Symptom Likely cause Fix
Only the visible viewport appears Default viewport dimensions were used. Set windowWidth: element.scrollWidth and windowHeight: element.scrollHeight.
Bottom content is missing from the PDF A tall image was placed on one page. Slice the canvas and call addPage() for each slice.
Images are blank or export throws a security error Cross-origin assets tainted the canvas. Use CORS-enabled image URLs, a proxy, or same-origin assets; useCORS: true alone is not sufficient.
A remote embed is empty It is a cross-origin iframe. It cannot be read by browser JavaScript; capture it separately or use a server-side renderer.
Text or cards are blurry Canvas scale is too low or the image was enlarged. Use a scale near the device pixel ratio, cap it around 2 for long pages, and preserve the aspect ratio.
The browser tab freezes or crashes The canvas is too large for available memory. Reduce scale, capture sections, simplify the DOM, or move rendering to a screenshot service.
Content shifts between runs Fonts, images, animations, or network data were not ready. Await document.fonts.ready, decode images, wait for data, and disable animations.
Fixed header repeats over every slice Positioned UI is being rendered with document content. Hide it in a capture-only stylesheet or use a dedicated print container.

Performance, reliability, and cost considerations

Canvas memory grows with pixel count: page width multiplied by page height and then by the square of the scale factor. A long, high-density page can exceed browser canvas limits even when the DOM itself is modest. A lower scale, narrower capture target, or section-by-section export is usually more reliable.

Client-side output depends on the visitor’s browser, fonts, network, CORS configuration, and device memory. For batch jobs, untrusted URLs, scheduled captures, or consistent rendering, a remote browser service avoids shipping this work to each user’s tab. Native print remains preferable when selectable text and print CSS are requirements rather than visual fidelity.

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

Or skip the browser setup

ScreenshotNeo returns a PNG, JPEG, WebP, or PDF from one GET request. It accepts the page like a visitor, removes cookie-consent banners, newsletter popups, and chat widgets before capture, and reports whether a response was a clean shot, bot check, blank page, timeout, failed load, or cache hit. Only clean shots are billed; the response includes X-Page-Verdict and X-Billed headers.

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

For API details, see the ScreenshotNeo documentation. Replace the example URL with the page you need.

Rank #4
NDYIN Portable Printers Wireless for Travel, N80 Bluetooth Thermal Printer
  • Wireless Bluetooth Printer: Portable thermal printer compatible with iPhone, Android phones, iPad and tablet computers via Bluetooth. For smartphones, please download the "Nada Print" App. You can also connect to laptops and computers for printing using a USB-C cable. (Note: Laptops and computers can only be connected via USB and require the installation of a driver first. Bluetooth connection is not supported.)
  • No-ink printing: Only supports US Letter and A4 size thermal paper.(Doesn't support regular paper) The no-ink portable thermal printer uses direct thermal technology, requiring no ink, toner or ribbons, making it environmentally friendly, cost-effective and time-saving. The thermal printer package comes with a roll of US Letter thermal printing paper. Note: When installing the paper, remember to switch the paper size switch on APP
  • Clear Print: NDYIN N80 portable thermal printer adopts high-definition printing technology, with a 203DPI resolution to provide you with clear printing results. This mobile printer is compatible with roll paper, folded paper and tattoo transfer paper, supporting printing from your mobile phone PDF, Word, pictures and web pages anytime and anywhere. It is recommended to use our NDYIN thermal paper to achieve good printing quality
  • Portable wireless printer for travel: The thermal printer is equipped with a built-in 1500mAh rechargeable battery, which can print 160 sheets of 8.5" x 11" thermal paper after being fully charged. It weighs only 1.5 pounds and is compact in size. This ink-free portable printer can be easily carried in a backpack or briefcase! It is perfect for business travel, cars, small offices, construction sites, schools and homes. You can print documents, contracts, invoices and boarding passes anytime and anywhere
  • The N80 thermal printer has a wide range of uses. The package includes the N80 printer, a roll of US Letter paper(7m/roll), a user manual, a guide card, a type-C soft cable and a type C adapter. Note: The charging adapter is not included. Special thermal paper is required for use; ordinary paper cannot be used. This ink-free portable thermal printer is suitable for various scenarios such as home, school, travel, office, and outdoor, meeting the printing needs of different groups of people. This tattoo template printer is also compatible with tattoo transfer paper, making it an ideal choice for tattoo art

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 buffer = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', buffer));

ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. Its options include full-page capture with lazy images loaded, CSS-selector element capture, device presets or custom viewports, dark mode, retina scale, PDF paper size and margins, custom CSS and JavaScript, click-before-capture actions, selector or network-idle waits, request blocking, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs are accepted to ease migration.

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

Yearly billing gives two months free, and every feature is available on every plan. Create a free ScreenshotNeo account to get 1,000 screenshots a month with no card.

FAQ

Can jsPDF create selectable text from html2canvas?

Not with this image-based workflow. The page is rasterized into a canvas before it is inserted into the PDF. Use native browser printing or a DOM-to-PDF approach designed to preserve text when selection and accessibility are required.

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

Why does increasing scale not restore missing content?

Scale changes pixel density, not the captured layout area. Missing bottom content usually means the capture used viewport dimensions or the PDF image was not paginated. Correct those first.

Should I use PNG or JPEG?

PNG preserves sharp text and flat UI graphics but can create large files. JPEG is smaller for photographic pages but introduces compression artifacts around text. Choose the format according to the page’s content and the quality requirements of the export.

Frequently Asked Questions

Can I capture a page wider than the viewport?

Yes. Capture a dedicated element and set html2canvas’s windowWidth to that element’s scrollWidth; then fit the resulting canvas to the PDF’s usable width while preserving its aspect ratio.

What is the safest way to export extremely long pages?

Capture logical sections separately or reduce canvas scale. One enormous canvas can exceed browser memory limits even when pagination code is correct.

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Read next

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.