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

When jsPDF creates a blank, incomplete, or visually inaccurate PDF from HTML, first identify which stage failed: dependency loading, browser rendering, image access, canvas sizing, pagination, or fonts. The doc.html() method relies on html2canvas to reconstruct the page; it is not a native browser screenshot and cannot reproduce every CSS feature. Check the conversion path with a small element, then follow the symptom-specific fixes below.

How jsPDF turns HTML into a PDF

jsPDF’s html() method accepts an HTMLElement or an HTML string. Its options include margins, pagination, image settings, html2canvas configuration, font faces, position, and width. The method depends on the optional html2canvas package. When you pass an HTML string rather than an element, the path also relies on dompurify. If either dependency is missing from your installed package or bundler output, a rendering symptom may actually be a dependency or dynamic-import problem.

The rendering stage matters. html2canvas traverses DOM and style information and draws its own representation of supported features. It does not take a native screenshot of what the browser displays, and some CSS properties are unsupported or only partly implemented. Thus a PDF can be generated successfully while still differing from the visible page.

Start with a minimal conversion

  1. Use a real browser page. html2canvas uses window, document, and computed styles; it cannot perform this stage in a plain Node.js runtime.
  2. Reduce the input. Try one small, same-origin element with simple text and styling. Remove unrelated widgets, images, and complex layout temporarily.
  3. Check dependencies and errors. Confirm html2canvas is available to your build. If you pass a string, also confirm dompurify. Inspect the browser console and build output for missing optional dependencies or dynamic-import errors.
  4. Save from the callback. This basic pattern waits for the HTML rendering operation before saving:
const element = document.querySelector('#report');
if (!element) throw new Error('Could not find #report');

doc.html(element, {
  callback: (pdf) => pdf.save('output.pdf')
});

Once the minimal element works, restore images, styling, and layout features one at a time. That makes it easier to distinguish a runtime problem from a resource or rendering limitation. Check option names against the jsPDF and html2canvas versions installed in your project: the html2canvas configuration documentation is not pinned to a release, and project documentation can change.

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

Fix missing images and other unloaded resources

If text appears but images do not, verify that the images have loaded before conversion, then check their origin. Browser security rules prevent a script from freely reading cross-origin image pixels into a canvas. With html2canvas’s default allowTaint: false, an image that would taint the canvas is skipped.

Choose an image-loading path

  • Same origin: Prefer images served from the same origin as the page where practical. Confirm the image URL is correct and the resource has loaded before calling doc.html().
  • Cross-origin with server permission: Set useCORS: true only when the image server returns an appropriate Access-Control-Allow-Origin header. The option requests CORS-enabled loading; it does not grant permission by itself.
  • Proxy where permitted: A same-origin proxy can retrieve eligible resources and serve them to the page, subject to your access rights and the resource owner’s policies. Do not use a proxy to evade access controls.

For diagnosis, enable html2canvas logging and use its onError callback to surface resource failures. If an image server does not permit cross-origin access, changing jsPDF settings cannot override that browser restriction. Do not set allowTaint as a supposed CORS fix: allowing a tainted canvas can make it unusable for reading or exporting image data.

Fix CSS that looks different in the PDF

html2canvas reconstructs an image from DOM and style data rather than capturing the browser’s rendered screen. When a CSS property is missing or only partially implemented, simplify or replace that effect with supported layout and styling. Check html2canvas’s supported-feature documentation for the property in question and build a minimal reproduction before changing the PDF code.

Also consider embedded content. Cross-origin iframe documents cannot be read by page JavaScript because the browser does not expose their contents; same-origin iframes are documented as supported. If the missing area belongs to a cross-origin frame, a change to jsPDF pagination or canvas scale will not make that document readable.

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.

Fix blank or truncated output

An oversized canvas can fail by producing blank or partly rendered output without a useful exception. Maximum canvas dimensions and total area vary by browser, operating system, GPU, and available device memory, so there is no single safe size to promise across environments.

  • Capture less: Test a smaller element or divide a long report into sections rather than rendering one enormous canvas.
  • Lower the scale: Reduce html2canvas’s scale option. This lowers the pixel dimensions and memory pressure, but also reduces image resolution.
  • Match the render window: If the viewport is clipping content, set windowWidth and windowHeight to dimensions appropriate to the element’s scroll dimensions. These options can address viewport sizing; they do not remove canvas limits.
  • Inspect the failure mode: Compare the canvas or PDF from a short input with one from the full input. If the short case works and the long case is blank or cuts off partway through, size and resource pressure are plausible causes.

Use the html2canvas FAQ and configuration documentation for the installed version’s available options. Treat any browser-specific canvas limits as approximate, not universal guarantees.

Choose pagination to avoid awkward page breaks

jsPDF html() defaults autoPaging to true. The documented modes make different trade-offs:

Mode Behavior Best fit
slice Fits content by slicing it; text can be cut at a page break. Content where splitting at a boundary is acceptable.
text Tries to avoid splitting text across pages. Mostly single-column text documents where keeping text together matters.

Try autoPaging: 'text' when paragraphs break mid-text. It is not a universal layout solution: inspect tables, positioned elements, and large blocks individually. Adjust the target width and margins to match the intended printable area, then review every page for overflow and unexpected blank space.

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

Fix garbled text or missing characters

jsPDF’s 14 standard PDF fonts are limited to the ASCII codepage. If the document needs characters outside that range, missing glyphs may appear as boxes or garbled text. Embed a TrueType font containing the required characters. The html() method’s fontFaces option supplies font-face information for use during HTML rendering. Verify that the chosen font actually includes the script and symbols in your content; selecting a font family name alone does not add glyphs to the PDF.

Use the right runtime for the rendering stage

jsPDF offers a Node build for PDF operations, but html2canvas needs browser DOM APIs and computed styles. Consequently, calling the HTML-rendering path in plain Node.js fails because the required browser environment is absent. For server-side HTML rendering, use a real browser driven by a tool such as Puppeteer or Playwright, as the html2canvas FAQ suggests, or choose a screenshot service that handles browser capture remotely.

When you only need the jsPDF HTML-to-PDF path, run it in a browser context. For server-side work, decide whether you need jsPDF’s PDF-generation features or a browser-generated capture; they are different approaches and have different rendering behavior.

Handle HTML input safely

The jsPDF project says: “We strongly advise you to sanitize user input before passing it to jsPDF!” Treat HTML strings and any user-controlled content as untrusted. Sanitization is still your responsibility; the fact that the string path uses DOMPurify does not make it safe to pass arbitrary input without considering your application’s security requirements.

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

For Node use, jsPDF restricts local filesystem reads by default and documents Node permission flags as the stronger enforcement mechanism. Keep file access narrowly scoped and follow the security guidance for the runtime and package version you deploy.

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 the actual need is a clean capture of a public webpage rather than jsPDF-specific PDF layout, ScreenshotNeo offers a one-request screenshot API. For a PDF, its API can return a PDF instead; see the ScreenshotNeo API documentation for request options and formats.

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 cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000. See ScreenshotNeo and its API documentation for setup and options. Sign up for 1,000 free screenshots a month with no card.

Common errors and what to try

Symptom Likely cause Next step
Missing module or import error Optional dependency unavailable in the package or build, or a dynamic import failed. Check the installed jsPDF package, bundler output, and whether the input is an element or string; strings also require DOMPurify.
Images absent Image not loaded, wrong URL, or cross-origin response lacks CORS permission. Confirm the resource loads, use useCORS only with server permission, or use an approved same-origin proxy.
Blank or partial canvas/PDF Very large canvas, memory pressure, or a resource/rendering failure. Reduce the capture region or scale; inspect logs and test a short document.
CSS effect missing html2canvas does not implement that feature fully, or content is in a cross-origin frame. Check supported features, simplify the effect, or render content available to the page.
Paragraphs split between pages Default slicing behavior or unsuitable page layout. Try autoPaging: 'text' for mostly single-column text, then adjust margins and width.
Non-Latin characters garbled Standard PDF font lacks the required glyphs. Embed a suitable TTF font and provide font-face information to html().
Works in browser, fails in Node html2canvas requires window, document, and computed styles. Run rendering in a browser or drive a real browser for server-side capture.

Sources and version considerations

The guidance here follows official jsPDF, html2canvas, and html2canvas FAQ documentation checked on September 30, 2026. The jsPDF API documentation reports generation on March 17, 2026; repository documentation is on a moving master branch, and html2canvas FAQ/config pages are not pinned to a release. Confirm dependency availability and option names against the versions in your application.

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

Frequently Asked Questions

Can jsPDF convert an HTML string as well as an element?

Yes. The html() API accepts either an HTMLElement or an HTML string; the string path also relies on DOMPurify.

Can useCORS make any remote image appear in the PDF?

No. The remote image server must grant cross-origin access with a suitable Access-Control-Allow-Origin response header.

Does autoPaging: ‘text’ prevent every awkward page break?

No. It tries to avoid splitting text and is best suited to mostly single-column documents; inspect complex tables and positioned content separately.

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.