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

First check whether the black area is already present in the canvas or appears only after the image is added to the PDF. That tells you where to fix it. For a predictable white PDF, set the html2canvas background to #ffffff, remove unintended dark backgrounds from the source DOM, export the canvas as PNG, and pass 'PNG' explicitly to jsPDF’s addImage. If transparency is required, keep the source background transparent and inspect the canvas before exporting; a PNG can preserve alpha, but a JPEG cannot.

Find out which stage turns the background black

A jsPDF export can involve several separate stages: the browser styles the page, html2canvas renders the selected element into a canvas, and jsPDF places the resulting image into a PDF. A black background can originate at any of these stages, or appear only in a PDF viewer. Changing a jsPDF drawing color will not repair a canvas that is already black.

  1. Inspect the page before capture. Check the body, the element being exported, its child containers, pseudo-elements, and any dark-mode styles for background or background-color.
  2. Render the element to a canvas and inspect that canvas in the browser before making the PDF. If it is black there, investigate the DOM, CSS, html2canvas rendering, or image decoding.
  3. If the canvas looks right, export it as a PNG and add it to a fresh PDF with the format supplied explicitly. If the PDF still looks black, isolate the addImage call, its format, compression settings if used, and the jsPDF version.
  4. If the PDF looks correct in one place but not another, compare viewers. A jsPDF issue report opened on January 12, 2022 describes a transparent PNG appearing black in Edge with jsPDF 2.4.0/2.5.0; the same report also mentions black JPEG backgrounds. That is evidence of a reported workflow-specific symptom, not proof of a universal jsPDF defect.

This step-by-step isolation avoids treating every black page as the same bug. In particular, a transparent source image, an opaque white page, and a viewer’s rendering of a PDF are different cases.

Choose whether the PDF should be white or transparent

For a white page

Set html2canvas’s backgroundColor to '#ffffff' and remove unintended dark backgrounds in the source DOM. This creates an intentional white canvas background rather than relying on how a transparent area is displayed later. It is usually the straightforward choice for a conventional document or report.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
  • Scanner type: Document
  • Connectivity technology: USB
  • With Auto Scan Mode, the scanner automatically detects what you're scanning
  • Digitize documents and images

For a transparent image

Keep the relevant DOM backgrounds transparent and verify that the canvas itself contains the transparency you expect. Export with canvas.toDataURL('image/png') and add it as PNG. PNG supports alpha; JPEG is opaque, so it cannot preserve transparent pixels. If the canvas has already filled transparent areas with black or white, changing the PDF’s fill color afterward will not restore the missing alpha.

There is an important distinction between image transparency and page color: jsPDF’s setFillColor selects the fill color for upcoming drawing operations, such as a rectangle you draw. It does not recolor pixels that are already inside an image added with addImage.

Use a controlled canvas-to-PDF export

The following browser-side pattern assumes html2canvas and jsPDF are available in your application. It deliberately produces white output. Pass the intended PDF page width and height in the same units used by your jsPDF document; choose dimensions that match your layout rather than stretching a mismatched canvas.

Rank #2
Sale
Brother DS-640 Compact Mobile Document Scanner, (Model: DS640)
  • FAST SPEEDS - Scans color and black and white documents a blazing speed up to 16ppm (1). Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
  • ULTRA COMPACT – At less than 1 foot in length and only about 1. 5lbs in weight you can fit this device virtually anywhere (a bag, a purse, even a pocket).
  • READY WHENEVER YOU ARE – The DS-640 mobile scanner is powered via an included micro USB 3. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan.
  • WORKS YOUR WAY – Use the Brother free iPrint&Scan desktop app for scanning to multiple “Scan-to” destinations like PC, Network, cloud services, Email and OCR. (2) Supports Windows, Mac and Linux and TWAIN/WIA for PC/ICA for Mac/SANE drivers. (3)
  • OPTIMIZE IMAGES AND TEXT – Automatic color detection/adjustment, image rotation (PC only), bleed through prevention/background removal, text enhancement, color drop to enhance scans. Software suite includes document management and OCR software. (4)
async function exportElementToPdf(element, pageWidth, pageHeight) {
  const canvas = await html2canvas(element, {
    backgroundColor: '#ffffff',
    useCORS: true,
    windowWidth: element.scrollWidth,
    windowHeight: element.scrollHeight
  });

  // Inspect this canvas if the exported result has a dark background.
  const imgData = canvas.toDataURL('image/png');
  const pdf = new jsPDF();

  pdf.setFillColor('#FFFFFF');
  pdf.setTextColor('#000000');
  pdf.addImage(imgData, 'PNG', 0, 0, pageWidth, pageHeight);
  pdf.save('output.pdf');
}

The explicit 'PNG' format matters: jsPDF documents JPEG as the default format when a canvas is passed without a format. Supplying the image data URL and format makes the intended PNG path clear. The color setters are included for any subsequent drawing or text operations; their settings apply to upcoming elements, not to pixels already rendered into the image.

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

useCORS: true is not a way around browser cross-origin restrictions. The remote image server must permit the request with an Access-Control-Allow-Origin response header. If it does not, arrange for a same-origin proxy or use an asset served from the same origin. With html2canvas’s default allowTaint: false, cross-origin images that would taint the canvas are skipped.

When html() or a background image is involved

If your workflow uses jsPDF’s html() path rather than rendering a canvas and calling addImage, inspect the generated containers as well as the original element. A March 20, 2024 jsPDF issue reports that html() rendered div containers with white backgrounds, interfering with a background image placed through doc.addImage(). This illustrates why a background can be changed before the image reaches the PDF. Check the actual rendered result and the containers created by your workflow rather than assuming the source element’s CSS is the only relevant style.

Rank #3
Plustek PS186 Desktop Document Scanner, with 50-Pages Auto Document Feeder (ADF). for Windows 7/8 / 10/11 (Intel/AMD only)
  • Up to 255 customize favorite scan file setting with "Single Touch" , Support Windows 7/8/10
  • Turn paper documents into searchable, editable files - save scans as searchable PDF files; OCR function included
  • Info Barcode function - automatic categorization of complicate documentation and data with 1D or 2D Barcode page.
  • Intelligent color and image adjustments — Auto Rotate, Crop, Deskew and blank page remove with Plustek Image Processing Technology
  • Easy send scanned files to FTP server or personal NAS (FTP) with PDFs , Jpeg , TIFF or Png format. User can download scanner driver from Plustek website

For diagnosis, the canvas-to-PNG route has a useful advantage: you can view the exact raster image that you intend to place in the PDF. If you need html() for your application, keep that route, but verify the resulting PDF separately and investigate the container backgrounds that its rendering path introduces.

Fix missing or incorrect images and blank captures

Cross-origin images disappear

When an image is hosted on another origin, html2canvas cannot bypass the browser’s content policy. Its documentation notes that useCORS: true works only when the image server sends the appropriate CORS permission; otherwise use a same-origin proxy. An image that is skipped is a different failure from an image that renders with a black background, so check whether the asset is present on the canvas at all.

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

Very large captures are blank or incomplete

Browser canvas size limits vary by platform, and exceeding a limit can produce blank or partially rendered output without a clear error. Reducing the capture size is a practical first diagnostic. The example sets windowWidth and windowHeight to the element’s scroll dimensions; those values help html2canvas render the element’s full scroll area, but do not remove platform canvas limits. For especially large pages, capture smaller sections rather than assuming a larger canvas will work.

Rank #4
Hczrc Portable Scanner, Photo Scanner for A4 Documents, Handheld Scanner for Business, Photo, Picture, Receipts, Books, JPG/PDF Format Selection, UP to 900 DPI, with 16G SD Car
  • Note: No software installation is required. You need 2 AA batteries ( not included) and a memory card ( included) to use it directly. Scan mode: Press and hold "Scan" for 2 seconds to turn on the device, and then press "Scan", the green light is on. The scanner moves to scan the file until the green light turns off automatically (or press the "Scan" key and the green light goes out). The number shown on the display increases by 1 to indicate that the scan is complete.
  • Portable Scanner scans images or pictures quickly: Store JPEG/PDF files within seconds, scan images or pictures quickly, plug and play, no need any software preinstalled. Compatible with Windows XP/7/Vista/Mac OS 10.4 or above version.
  • Lightweight and travel-friendly: Stored in Micro SD card directly, support read data on your computer or phone with USB connected. Powered by 2pcs AA batteries, Compact Design, it is convenient to carry outside.
  • 3 Image Resolution: 3 modes of resolution for your options: 300dpi/600dpi/900dpi, you can save it at the clearest way, picture and document are showed clear as it is. Freely choose your favorite resolution.File Format: JPEG/PDF format is all available, Great storage capacity as it supports 32G Micro SD card(Included 16GB Card),total meet your need for business trip or daily use.
  • Widely Used: It is applicable in bank, insurance business, real estate agency,home, office, library or outdoors. suitable for lawyer, businessmen, students, travelers and amateur archivists. Scan your important files and save them immediately, no struggling in finding a printing shop, keep it confidential.

Common causes and fixes

What you see Likely stage What to check
The canvas is already black DOM, CSS, html2canvas, or image rendering Inspect backgrounds on the body, target, child containers, pseudo-elements, and dark-mode styles; then verify the source assets.
The canvas is correct but PDF image is black Image handoff to jsPDF or PDF rendering Use PNG data from toDataURL('image/png'), specify 'PNG' in addImage, and compare the result in another viewer.
Remote images are absent Cross-origin policy Allow the origin on the image server or use a same-origin proxy. useCORS alone does not grant access.
Only part of a long page appears, or the canvas is blank Browser canvas dimensions Reduce the capture size or split it into smaller sections; platform limits vary.
A background image conflicts with rendered containers jsPDF html() rendering path Inspect the generated div backgrounds and test a direct canvas-to-PNG path to isolate the stage.
The problem began after a dependency upgrade Version-specific behavior Reproduce with the previous project version and a current version. A single issue report does not establish a regression affecting every workflow.
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 your goal is to capture a web page as an image or PDF rather than export a custom application element with jsPDF, ScreenshotNeo offers a one-request screenshot API. It does not replace debugging a jsPDF document built from your own canvas; it is an alternative when you want a website capture without setting up the browser-rendering pipeline yourself.

Example cURL request (see the ScreenshotNeo API documentation):

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

ScreenshotNeo accepts and removes cookie or consent banners before capture, along with more than 60 known consent platforms, newsletter popups, and chat widgets; each of those cleanup steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents using Claude, Cursor, or another MCP client. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots, and every feature is available on every plan.

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.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Best Value
Sale
Epson Workforce ES-50 Compact & Lightweight Mobile Document Scanner
  • PORTABLE SCANNER FOR USE ON-THE-GO — The fastest and lightest mobile single-sheet-fed compact document scanner in its class¹
  • QUICK DOCUMENT SCANNING ― This Epson ultra-fast scanner scans a single page as quickly as 5.5 seconds²; Windows and Mac compatible
  • VERSATILE PAPER HANDLING ― Portable scanner scans documents up to 8.5 x 72 in; Also easily digitizes receipts and ID cards to make accounting, bookkeeping, and organizing simpler
  • INTUITIVE, HIGH-SPEED SOFTWARE — Epson ScanSmart Software³ is a smart tool allowing you to easily scan, review, and save; Stay organized easily with the help of this Epson scanner
  • EASY SETUP — USB-powered connect to your computer for quick and simple scanning; No batteries or external power supply required to operate portable document scanner; Standard Connectivity: USB 2.0

Frequently Asked Questions

Does a black background in Edge prove jsPDF is broken?

No. The January 2022 issue documents a particular reported workflow involving jsPDF 2.4.0/2.5.0 and Edge; it does not establish that all jsPDF PDFs or viewers have the same defect.

Can I make only one element transparent while keeping the page white?

Yes, in principle: transparency is an image-pixel property while the page or other drawn shapes can have an opaque fill. Verify the canvas alpha and the final PDF separately, because the capture stage can change the result before jsPDF receives it.

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.

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.