October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
html2canvas

How to Prevent html2pdf.js from Automatically Downloading a PDF

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

To stop html2pdf.js from downloading immediately, do not call .save() (or .saveAs()). Build the document through .toPdf(), then consume it with .output('blob'), .outputPdf('blob'), or another jsPDF output type. The returned Promise gives your application the PDF data for an inline preview, a new tab, an upload, or a later download button.

const element = document.getElementById('element-to-print');

html2pdf()
  .from(element)
  .toPdf()
  .output('blob')
  .then((blob) => {
    const url = URL.createObjectURL(blob);
    document.querySelector('#pdf-preview').src = url;
  });

Why html2pdf.js downloads by default

The convenience call html2pdf(element) follows the library’s save-oriented workflow and prompts the visitor to save the generated PDF. The documented Worker sequence is .from() → .toContainer() → .toCanvas() → .toImg() → .toPdf() → .save(). The final save stage, not PDF generation itself, creates the browser download prompt.

saveAs() is an alias for save(), so changing the filename or switching between those two methods does not make the operation silent. A filename option also only names a file; it does not initiate a download on its own.

Use an output method instead of .save()

Stop the chain after .toPdf() and choose an output that matches what your application needs. html2pdf.js exposes outputPdf(type, options), which forwards to jsPDF’s output method and returns a Promise. The shorter output(type, options) form is also available; export is an alias for output.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Brother Compact Monochrome Laser Printer, HLL2395DW, Flatbed Copy & Scan, Wireless Printing, NFC with Refresh Subscription Free Trial and Amazon Dash Replenishment Ready
  • Engineered for convenience – This new Brother Monochrome Laser Printer is conveniently equipped with a flatbed scan glass for quick copying and scanning. Mobile Device Compatibility AirPrint, Google Cloud Print 2.0, Brother iPrint and Scan, Mopria, Cortado Workplace
  • Optimized for efficiency – Engineered with new features, the HL L2395DW laser printer (replacement for the HLL2380DW) and has been optimized for efficiency, allowing you to print up to 36 pages per minute(1)
  • Faster, high quality prints: This monochrome laser printer is built with a 250 sheet paper capacity that helps improve efficiency due to less time spent refilling trays. It also handles both letter and legal sized paper. Power Source AC 120V 50/60Hz.Machine Noise (Ready/Printing): 30dB / 50dB
  • Cloud based print & scan – Print from and scan to popular Cloud services directly from the 2.7" color touchscreen, including Dropbox, Google Drive, Evernote, OneNote, and more(4)
  • Wireless printing & exceptional support – This printer’s simple to connect wireless technology allows you to submit print jobs from your laptop, smartphone, desktop, and tablets(2). The "Touch to connect" printing with NFC delivers added convenience(3).
Goal Pattern Result
Preview or upload binary data .output('blob') or .outputPdf('blob') A Promise resolving to a Blob
Open or pass around encoded data An appropriate jsPDF output type through output Data in the format selected for that jsPDF output
Let the browser prompt for a file .save('name.pdf') User download prompt

The important control boundary is whether your code calls save. Generation can complete successfully without any download at all.

Show the PDF inside the page

A Blob URL lets an iframe or embed element display the PDF without creating an anchor with a download attribute.

const element = document.getElementById('element-to-print');
const preview = document.getElementById('pdf-preview');

html2pdf()
  .from(element)
  .toPdf()
  .outputPdf('blob')
  .then((blob) => {
    const objectUrl = URL.createObjectURL(blob);
    preview.src = objectUrl;
    preview.dataset.objectUrl = objectUrl;
  })
  .catch((error) => {
    console.error('PDF generation failed:', error);
  });

Use markup such as <iframe id='pdf-preview' title='PDF preview'></iframe>. Keep the object URL while the preview is visible. When the preview is removed or replaced, call URL.revokeObjectURL(preview.dataset.objectUrl) so the browser can release that Blob URL.

Open a preview in a new tab without popup-blocker surprises

Browsers generally allow a new window only when it is opened synchronously inside a user-initiated event. Open a placeholder tab in the click handler, then perform the asynchronous conversion and navigate that tab after the Blob is ready.

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.
document.getElementById('preview-button').addEventListener('click', () => {
  const tab = window.open('about:blank', '_blank');

  if (!tab) {
    alert('Allow pop-ups for this site to preview the PDF.');
    return;
  }

  const element = document.getElementById('element-to-print');

  html2pdf()
    .from(element)
    .toPdf()
    .output('blob')
    .then((blob) => {
      const objectUrl = URL.createObjectURL(blob);
      tab.location.href = objectUrl;
    })
    .catch((error) => {
      tab.close();
      console.error('PDF generation failed:', error);
    });
});

If you call window.open() only after the Promise resolves, a popup blocker may reject it. A new tab also has its own object-URL lifetime; revoke the URL when your application no longer needs it, while avoiding revocation before the tab has loaded the document.

Rank #2
Brother MFC-L3710CW Compact Digital Color All-in-One Printer Providing Laser Printer Quality Results with Wireless, Amazon Dash Replenishment Ready
  • FAST PRINT AND SCAN: The Brother MFC-L3710CW lets you get things done with up to 19 ppm print speed and scans up to 29 ipm in black and 22 ipm in color
  • AFFORDABLE AND FLEXIBLE COLOR PRINTING: Affordably print professional quality, rich, vivid color documents with laser printer quality. The 250 sheet adjustable paper tray helps minimize refills and the manual feed slot handles varied printing needs
  • 3.7” COLOR TOUCHSCREEN: Print from and scan to popular cloud apps directly from the 3.7" color touchscreen including Dropbox, Google Drive, Evernote, OneNote and more. Save time by creating custom shortcuts on the touchscreen for your most used features.
  • PRINT AND CONNECT YOUR WAY: Print wirelessly from your desktop, laptop, smartphone and tablet with built-in wireless, and Wi-Fi Direct or connect locally to a single computer via USB interface.
  • UNIT DIMENSIONS (WxDxH): 16.1” W x 18.7” D x 16.3” H

Upload the PDF instead of downloading it

For an application workflow, send the Blob directly to your server. This keeps the file in memory and avoids creating a download link.

async function createAndUploadPdf() {
  const element = document.getElementById('element-to-print');
  const blob = await html2pdf()
    .from(element)
    .toPdf()
    .outputPdf('blob');

  const form = new FormData();
  form.append('document', blob, 'generated.pdf');

  const response = await fetch('/api/documents', {
    method: 'POST',
    body: form
  });

  if (!response.ok) {
    throw new Error(`Upload failed: ${response.status}`);
  }

  return response.json();
}

Use your server’s authentication and size limits as usual. The browser does not need an <a download> element for this path.

A complete silent-generation helper

Wrapping the chain in a function gives callers a predictable Promise and leaves the final presentation decision to the UI.

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.
function renderPdfBlob(element, options = {}) {
  return html2pdf()
    .set(options)
    .from(element)
    .toPdf()
    .outputPdf('blob');
}

document.getElementById('make-preview').addEventListener('click', async () => {
  const preview = document.getElementById('pdf-preview');
  const oldUrl = preview.dataset.objectUrl;

  if (oldUrl) URL.revokeObjectURL(oldUrl);

  try {
    const blob = await renderPdfBlob(
      document.getElementById('element-to-print'),
      {
        filename: 'report.pdf',
        margin: 10,
        image: { type: 'jpeg', quality: 0.95 },
        html2canvas: { scale: 2 },
        jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
      }
    );

    const objectUrl = URL.createObjectURL(blob);
    preview.dataset.objectUrl = objectUrl;
    preview.src = objectUrl;
  } catch (error) {
    console.error(error);
  }
});

The filename setting remains useful if you later add an explicit download button, but it does not change the silent behavior of this helper.

What does not prevent the download

  • Changing filename only changes the suggested name.
  • Changing image, html2canvas, or jsPDF options changes rendering or PDF settings, not the save behavior.
  • Replacing save() with saveAs() still invokes the same download prompt.
  • Calling output() and then later calling application code that creates an <a download> element and clicks it will still download the file. Remove that separate code if you want a completely silent flow.

Troubleshooting automatic downloads

The PDF still downloads after removing .save()

Search the whole codebase for html2pdf(, .save(, and .saveAs(). A second conversion path, a shared helper, or a button handler may still use the convenience call. Also search for download, dynamically created anchors, and programmatic click() calls.

Rank #3
MixPad Free Multitrack Recording Studio and Music Mixing Software [Download]
  • Create a mix using audio, music and voice tracks and recordings.
  • Customize your tracks with amazing effects and helpful editing tools.
  • Use tools like the Beat Maker and Midi Creator.
  • Work efficiently by using Bookmarks and tools like Effect Chain, which allow you to apply multiple effects at a time
  • Use one of the many other NCH multimedia applications that are integrated with MixPad.

The preview is blank

First verify that the Promise resolved and that the Blob has a PDF MIME type. Then inspect the iframe or embed source and browser console. A blank preview is a rendering or browser-display issue, not evidence that .output('blob') triggered a download. Test the html2canvas and jsPDF portions separately before changing download handling.

The new tab is blocked

Open it synchronously in the user-event handler, before starting the asynchronous html2pdf.js chain. If window.open() returns a falsy value, tell the user to allow pop-ups or fall back to an inline preview.

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

An upload fails while preview works

Check the server’s multipart field name, authentication, request-size limit, and response status. Append the Blob to FormData with an explicit filename and do not manually set the multipart boundary header; the browser sets it correctly.

Content is missing or looks different

html2pdf.js is client-side software that uses html2canvas and jsPDF. The rendered page is placed into an image in the PDF, so text may not be selectable or searchable and files can be larger than a text-native PDF. Cloning, resizing, canvas-size, Promise, and other rendering limitations can affect the result. Fix layout, cross-origin assets, and canvas constraints independently of the download decision.

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

Choose the right browser behavior

Desired experience Implementation Browser consideration
Silent generation for later processing Resolve output('blob') and keep the Blob in application state Manage memory for large documents
Inline review Create an object URL and assign it to an iframe or embed Revoke the URL when the preview is discarded
Separate tab Open a placeholder during the click, then assign the object URL Opening after asynchronous work can trigger popup blocking
Explicit user download Call save() only from the download button The prompt occurs by design

Or skip the browser setup

If your actual requirement is a screenshot or PDF of a URL rather than a PDF assembled from the current browser DOM, ScreenshotNeo provides a one-request API. It is not a replacement for html2pdf.js when you must capture unsaved client-side state, but it avoids shipping browser-rendering code to your users.

Rank #4
Corel PDF Fusion Software
  • Save money by using PDF Fusion to view over 100 file formats without having to purchase additional software
  • Merge incompatible files quickly and easily by dragging and dropping in PDF Fusion to create a new PDF documents
  • Save time with PDF Fusion's editing tools to reuse the content from existing documents without starting from scratch

See the parameter reference in the ScreenshotNeo documentation. A basic image request with cURL is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The same request in Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

And in 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}`);

ScreenshotNeo accepts PNG, JPEG, WebP, or PDF output and can handle full-page captures, lazy images, CSS-selector element captures, device and viewport settings, dark mode, custom CSS and JavaScript, waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, resizing, caching, signed links, asynchronous jobs, webhooks, bulk capture, and usage reporting. Its cleanup step accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled.

Only clean shots are billed. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and each response identifies the result with X-Page-Verdict and X-Billed headers. An MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

The Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing gives two months free, and every feature is included on every plan. Create a free ScreenshotNeo account to try it without a card.

Frequently Asked Questions

Can I keep a generated PDF for a later download?

Yes. Store the resolved Blob or its object URL in your application state, then call save() only when the user presses an explicit download control.

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

Does html2pdf.js run as a Node.js PDF service?

No. html2pdf.js is client-side browser software built around html2canvas and jsPDF. A server-side workflow needs a different rendering service or browser automation stack.

Why is text in my PDF not selectable?

html2pdf.js places rendered content into an image in the PDF. Image-based output can therefore lose text selection and searchability and may produce larger files.

Quick Recap

Bestseller No. 3
MixPad Free Multitrack Recording Studio and Music Mixing Software [Download]
MixPad Free Multitrack Recording Studio and Music Mixing Software [Download]
Create a mix using audio, music and voice tracks and recordings.; Customize your tracks with amazing effects and helpful editing tools.
Bestseller No. 4

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver 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.