October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
CORS

How to Fix Missing Images in PDFs Generated With html2pdf.js

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

If images disappear from an html2pdf.js PDF, first check whether their final image URLs are cross-origin. html2pdf.js uses html2canvas to render the page element before jsPDF builds the PDF; the browser may prevent html2canvas from reading a cross-origin image into its canvas. Set useCORS: true and configure the image server to allow your page’s origin, or use a carefully restricted proxy you control. Also confirm images have finished loading: readiness and permission to read a cross-origin image are separate problems.

How html2pdf.js handles images

html2pdf.js is a browser-side pipeline: it renders an element using html2canvas, then creates a PDF with jsPDF. You pass html2canvas settings inside the html2canvas property of the html2pdf.js configuration. The renderer reconstructs the result from the DOM and styles; it is not a native browser screenshot. That distinction matters both for external images and for differences in layout or CSS rendering.

The primary cause of omitted external images is the browser’s cross-origin canvas security policy. By default, html2canvas does not allow a draw operation that would taint the canvas, so it skips resources it cannot safely read. As the html2canvas project documentation puts it, “html2canvas cannot circumvent content policy restrictions set by your browser.” html2canvas FAQ

Diagnose the missing image before changing configuration

  1. Check the live page. Confirm that the image appears in the page before export. Inspect the actual src, including any URL assigned after the initial page load. In browser developer tools, look for failed requests, redirects, authentication requirements, hotlink restrictions, and Console errors.
  2. Compare origins. An origin consists of the scheme, host, and port. Compare the page’s origin with the image’s final response origin after redirects. If they differ, inspect the response headers and determine whether the image server allows the page’s origin.
  3. Separate loading from access. A request can be slow or broken, so the renderer starts too early; alternatively, an image may appear on the page but remain unreadable to canvas because of CORS. Waiting can address the first condition, but not the second.
  4. Check for iframes. Content in a cross-origin iframe cannot be accessed by the rendering page under the browser restrictions described by html2canvas. An image inside such a frame may require an authorized export path or rendering the content in an accessible context. html2canvas documentation

Fix cross-origin images with CORS or a controlled proxy

Choose the remedy based on whether you can change the image server. If you control it, CORS is usually the simpler path. If you cannot configure its response, a proxy you operate can fetch the image and serve it from an origin your page can read. Neither option should be treated as a way to bypass a resource owner’s access controls.

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
Amazon Basics Multipurpose Copy Printer Paper, 8.5 x 11 Inches, 20 lb, 92 Bright, White, 1 Ream (500 Sheets), Jam-Free
  • 1 ream (500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
  • Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
  • Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
  • Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
  • Virgin copy paper providing professional quality results; acid-free to prevent yellowing
Approach Use it when What must be true Trade-off
CORS-enabled image response You control the image host or can ask its operator to configure it. The response must include an appropriate Access-Control-Allow-Origin header permitting the page origin. Direct loading avoids operating a proxy, but the server must grant permission. Setting a client option alone is insufficient.
Same-origin proxy The external host cannot be configured to allow your page’s origin. Your proxy must be authorized to retrieve the resource and serve it in a form the browser can read. You take on hosting, access-control, validation, and abuse-prevention responsibilities.

html2canvas documents both CORS and a proxy as ways to load cross-origin images. Its proxy option is documented as null by default; the getting-started guidance describes a proxy that returns the resource as a base64 data URI. html2canvas configuration html2canvas proxy guidance

For a proxy, allow only destinations you intend to support, validate inputs, and restrict who can use it. An unrestricted endpoint that fetches arbitrary URLs can be abused. If the image needs credentials, do not forward sensitive credentials to a destination the user or caller can choose; define an explicit authorization model instead.

Pass html2canvas options through html2pdf.js

For a CORS-enabled image host, configure useCORS inside the nested html2canvas object:

Rank #2
HP Printer Paper | 8.5 x 11 Paper | Copy &Print 20 lb | 1 Ream Case - 500 Sheets| 92 Bright | FSC Certified | 200060
  • HP Papers is sourced from renewable forest resources and has achieved production with 0% deforestation in North America. Each ream is wrapped in a polyurethane coated paper wrapper to protect the cut sheets from moisture damage
  • Sheet size – 8.5 x 11; Thickness – 20 pounds; Brightness – 92 bright white
  • HP Copy&Print20 20 pounds printer paper is Forest Stewardship Council (FSC) certified and contributes toward satisfying credit MR1 under LEED (Leadership in Energy and Environmental Design)
  • All HP Papers provide premium performance on HP equipment, as well as on all other printer and copier equipment; 100% satisfaction guaranteed; ColorLok technology provides more vivid colors, bolder blacks and faster drying
  • Superior quality, reliability, and dependability for high-volume printing at home, at school and in the office; HP Copy&Print20 print and copy paper prevents yellowing over time to ensure a long-lasting appearance for added archival quality
html2pdf().set({
  html2canvas: {
    useCORS: true
  }
}).from(element).save();

This is the documented integration pattern: html2pdf.js accepts html2canvas options in its html2canvas configuration property. Check the worker chain and API against the version installed in your project, since no version-specific reproduction establishes that every release has identical behavior. html2pdf.js README

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.

useCORS: true requests CORS-mode image loading; it does not grant permission by itself. The server still has to authorize the page origin in its response. The documented default for useCORS is false. html2canvas configuration

If using the proxy path, configure the proxy option for the html2canvas version in use and verify its expected URL and response format against that version’s documentation. Do not assume allowTaint: true is a substitute: allowing a tainted canvas does not make it readable for the image output needed by PDF generation. html2canvas documents allowTaint as false by default.

Rank #3
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 3 Reams (1,500 Sheets), 92 Bright White for Home Use
  • 3 ream case (1,500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
  • Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
  • Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
  • Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
  • Virgin copy paper providing professional quality results; acid-free to prevent yellowing

Wait for images before starting the PDF

When a PDF begins rendering before images finish loading, wait for each image to load or fail and inspect its dimensions. This helps find broken URLs and timing races; it does not remove CORS restrictions.

async function waitForImages(root) {
  const images = Array.from(root.querySelectorAll('img'));

  await Promise.all(images.map((img) => {
    if (img.complete) return Promise.resolve();

    return new Promise((resolve) => {
      img.addEventListener('load', resolve, { once: true });
      img.addEventListener('error', resolve, { once: true });
    });
  }));

  const failed = images.filter((img) => img.naturalWidth === 0 || img.naturalHeight === 0);
  return failed;
}

const element = document.querySelector('#pdf-content');
const failedImages = await waitForImages(element);
if (failedImages.length) {
  console.warn('Images that did not load:', failedImages.map((img) => img.src));
}

await html2pdf().set({
  html2canvas: { useCORS: true }
}).from(element).save();

The event check above handles ordinary <img> elements. If your application inserts images later, wait for the code that performs that insertion before collecting the elements. For CSS background images or content in nested frames, this <img>-only check is not sufficient.

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

Useful debugging options and their limits

Option Documented behavior Use and limitation
useCORS Default false; attempts CORS image loading. Use when the server grants the page origin access. It cannot override a server that declines the request.
proxy Default null; proxy URL used to load cross-origin images. Use a controlled proxy with appropriate access restrictions and the response format expected by the installed version.
allowTaint Default false. Not a practical fix when the renderer needs to read the canvas to produce output.
imageTimeout Default 15000 milliseconds. Increasing it may help slow resources finish loading, but cannot fix a rejected cross-origin request.
logging Documented debugging option. Enable it while diagnosing resource-loading or rendering behavior.
onclone Callback for modifying the cloned document used in rendering. Useful for render-only adjustments; it does not grant cross-origin access.

These defaults and options are documented by html2canvas; confirm them for the version actually installed. html2canvas configuration

Rank #4
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 5 Reams (2,500 Sheets), 92 Bright White
  • 5 ream case (2,500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
  • Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
  • Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
  • Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
  • Virgin copy paper providing professional quality results; acid-free to prevent yellowing

When the image is present but the PDF still looks wrong

If an image appears but its positioning, size, or surrounding styles differ, the problem may be rendering fidelity rather than image access. html2canvas rebuilds output from DOM and CSS information instead of taking a literal screenshot, and its rendering support has limits. Review the documented supported features and simplify or adjust the render-specific markup where appropriate. If exact browser-rendered fidelity is essential, consider an export architecture that captures the content in an accessible browser context rather than relying on DOM reconstruction. html2canvas documentation

For isolation, render the same element directly with html2canvas while enabling logging, then compare it with the html2pdf.js output. If the image is already absent from the direct canvas render, focus on URL loading, timing, origin policy, and iframe access. If it exists there but not in the PDF, investigate the html2pdf.js integration and the installed versions of its dependencies.

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

Troubleshooting by symptom

What you see Likely cause Next action
A same-origin image request fails. Bad or unavailable URL, authentication, or timing. Inspect the request status and final URL; confirm the image is loaded before rendering and check naturalWidth and naturalHeight.
A cross-origin request fails or the Console reports CORS. The image server does not permit the page origin. Set useCORS: true and configure the response to allow the page origin, or use a controlled proxy.
The page shows the image, but the canvas or PDF does not. The renderer cannot read the resource, or rendering started before it was ready. Check the final response origin and CORS headers, then verify load completion separately.
Image content is inside a cross-origin iframe. The page cannot access the frame’s content under browser restrictions. Render it in an authorized accessible context or use another authorized export route.
The image is present, but styling or layout differs. DOM/CSS reconstruction limits or unsupported rendering behavior. Compare a direct html2canvas render, review supported features, and adjust the export markup or rendering approach.

A project issue titled “PDF does not show images” illustrates that developers report this symptom, but issue comments are anecdotal rather than authoritative compatibility guidance. html2pdf.js issue

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
HP Printer Paper | 8.5 x 11 Paper | Office 20 lb | 3 Ream Case - 1500 Sheets | 92 Bright | Made in USA - FSC Certified | 112090C, White
  • Made in USA: HP Papers is sourced from renewable forest resources and has achieved production with 0% deforestation in North America.
  • Optimized for HP technology: All HP Papers provide premium performance on HP equipment, as well as on all other printer and copier equipment.
  • Perfect everyday office paper: Superior quality, reliability, and dependability for high-volume printing at home, at school and in the office. Perfect for everyday black and white printing.
  • Certified sustainable: HP Office20 20lb printer paper is Forest Stewardship Council (FSC) certified and contributes toward satisfying credit MR1 under LEED (Leadership in Energy and Environmental Design).
  • ColorLok technology printing paper: ColorLok technology provides more vivid colors, bolder blacks and faster drying.

Or skip the browser setup

If you need a clean image or PDF of a public web page rather than a PDF generated from your own application’s DOM, ScreenshotNeo offers a one-request screenshot API. It is not a fix for images embedded in an html2pdf.js export: use the CORS or proxy steps above for that. For a page capture, a cURL example is:

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 details. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up free for ScreenshotNeo.

Performance, reliability, and cost considerations

For an html2pdf.js export, increasing imageTimeout can give slow images more time, but it can also make the export wait longer and will not cure CORS denial. Fixing the image host’s CORS policy avoids the extra network hop and operational dependency of a proxy. A proxy can be useful when you cannot configure the host, but its reliability depends on the proxy and remote resource, and it needs safeguards against arbitrary fetches. No measured performance comparison establishes one approach as universally faster.

For ScreenshotNeo page captures, the stated plans are monthly: Free includes 1,000 shots with no card; Starter is $5 for 3,000; Growth $15 for 15,000; Pro $39 for 60,000; Scale $99 for 250,000; and Business $249 for 1,000,000. Yearly billing gives two months free, and every feature is on every plan. Those API plan allowances and prices do not describe html2pdf.js itself or resolve browser CORS policy.

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

Frequently Asked Questions

Does useCORS: true bypass CORS restrictions?

No. It requests CORS-mode loading, but the image server must permit the page origin in its response.

Will waiting longer or raising imageTimeout make a blocked image appear?

No. It may help a slow image finish loading; it cannot grant cross-origin permission.

Can ScreenshotNeo repair images missing from my html2pdf.js-generated PDF?

No. ScreenshotNeo captures web pages through its screenshot API; it does not change the image access rules in your html2pdf.js pipeline.

Quick Recap

Bestseller No. 1
Amazon Basics Multipurpose Copy Printer Paper, 8.5 x 11 Inches, 20 lb, 92 Bright, White, 1 Ream (500 Sheets), Jam-Free
Amazon Basics Multipurpose Copy Printer Paper, 8.5 x 11 Inches, 20 lb, 92 Bright, White, 1 Ream (500 Sheets), Jam-Free
1 ream (500 sheets) of 8.5 x 11 white copier and printer paper for home or office use; Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$6.97
Bestseller No. 2
HP Printer Paper | 8.5 x 11 Paper | Copy &Print 20 lb | 1 Ream Case - 500 Sheets| 92 Bright | FSC Certified | 200060
HP Printer Paper | 8.5 x 11 Paper | Copy &Print 20 lb | 1 Ream Case - 500 Sheets| 92 Bright | FSC Certified | 200060
Sheet size – 8.5 x 11; Thickness – 20 pounds; Brightness – 92 bright white
$6.97
Bestseller No. 3
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 3 Reams (1,500 Sheets), 92 Bright White for Home Use
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 3 Reams (1,500 Sheets), 92 Bright White for Home Use
Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$23.99
Bestseller No. 4
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 5 Reams (2,500 Sheets), 92 Bright White
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 5 Reams (2,500 Sheets), 92 Bright White
Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$34.85

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.

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
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

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.