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.

The right method depends on who should create and save the PDF. For a button that lets a visitor save the page, call window.print() and prepare the layout with print CSS; the visitor chooses a PDF destination in the browser or operating-system print dialog. For an automatic PDF file or buffer, use a browser automation tool such as Puppeteer or Playwright. For a client-side download of a page element, html2pdf.js is an option, with important image-rendering and text limitations.

window.print() alone does not silently download a PDF. JavaScript running in an ordinary webpage cannot use that API to choose a destination and write a file without the user’s involvement.

Choose the method that matches the result you need

Need Use What happens
A visitor initiates printing or saving window.print() with print CSS The browser opens its print dialog. The visitor selects a PDF destination if one is available.
A client-side download of a page or element html2pdf.js The browser converts the selected content through a canvas and image-based PDF workflow.
A server job, batch process, or automated test needs PDF bytes or a file Puppeteer or Playwright Code controls an automated browser and calls its page PDF API.

These options are not interchangeable. The browser print route gives the user control over the destination; html2pdf.js is convenient when an image-based PDF is acceptable; automated browsers expose a programmatic output workflow but require you to manage a browser process and its deployment.

Let the user save the current page with window.print()

MDN describes window.print() as opening the print dialog for the current document. Call it in response to a user action:

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
<button type="button" onclick="window.print()">Save as PDF</button>

The user then selects a PDF destination offered by their browser or operating system. The available choices vary, so do not describe this as a guaranteed direct download. The call waits for the dialog to close; if the document is still loading, the browser finishes loading it before opening the dialog.

Prepare a print-friendly layout

Use print styles to remove controls and navigation that do not belong in the exported document. The @page rule can set page dimensions, orientation, and margins, subject to the browser’s print behavior and the user’s dialog settings.

@media print {
  .no-print,
  nav,
  footer {
    display: none !important;
  }

  main {
    width: auto;
  }
}

@page {
  margin: 12mm;
}

You can put these rules in your normal stylesheet or link a print-only stylesheet using media="print". Check the result in the browsers your users rely on: print dialogs may include their own settings for margins, backgrounds, paper, and destination, and page JavaScript does not fully control those choices.

Handle temporary UI changes carefully

The browser fires beforeprint and afterprint events around printing. They can be useful when a page needs to adjust interface state for print and restore it afterward. Prefer print CSS for presentation changes; JavaScript event handling should be reserved for state that CSS cannot reasonably handle.

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

Download a page element in the browser with html2pdf.js

Use html2pdf.js when the user needs a client-side download of a selected element and the output’s rendering and text behavior suit the document. Its documented workflow runs in a browser and can be installed in a Node-based project, but it is not a Node-side HTML renderer.

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

After adding the library to the page, select the element and call its Promise-based workflow:

const element = document.getElementById("content-to-export");

if (!element) {
  throw new Error("PDF content element was not found");
}

html2pdf().from(element).save();

The project README documents options for the output filename, margins, image type and quality, html2canvas scale, and jsPDF paper settings. Set these deliberately for the version and document you deploy rather than relying on defaults. For example, choose a descriptive filename and test the paper format, orientation, and margins with representative content.

Know the conversion trade-offs

html2pdf.js follows a source-to-container-to-canvas-to-image-to-PDF pipeline. The resulting page content is image-based, so text is not selectable or searchable, and files can be large. Its project documentation also lists imperfect rendering, CSS handling issues in cloned nodes, reflow caused by root resizing, and blank output when canvas dimensions exceed supported limits.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Test long pages, large images, web fonts, tables, and page breaks at the sizes your users actually export.
  • Check whether the output remains readable at its intended paper size and whether text search or selection is a requirement.
  • If an export is blank, investigate canvas-size limits and the dimensions of the captured content.
  • If fidelity is critical, compare the generated result against browser print output rather than assuming the canvas conversion reproduces every CSS feature.

Generate a PDF programmatically with Puppeteer

For automated jobs, Puppeteer can launch a browser, open a page, and write a PDF file. Its PDF generation uses print CSS by default, returns PDF bytes, and waits for fonts by default. The following Node.js example writes the returned PDF bytes to disk:

import puppeteer from "puppeteer";
import { writeFile } from "node:fs/promises";

const browser = await puppeteer.launch();

try {
  const page = await browser.newPage();
  await page.goto("https://example.com", { waitUntil: "networkidle0" });

  const pdf = await page.pdf({
    path: "page.pdf",
    format: "A4",
    printBackground: true
  });

  // page.pdf() also returns the PDF bytes if you need to process them.
  console.log(`Generated ${pdf.length} PDF bytes`);
} finally {
  await browser.close();
}

Install Puppeteer in your project using its current official installation guidance; browser download and deployment requirements depend on the environment and package setup. If the target page builds content asynchronously, wait for the relevant selector or application-ready signal before calling page.pdf(). A generic network-idle condition may not suit pages that keep connections open or load content after initial navigation.

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

The API supports output settings such as paper format, dimensions, and margins. Consult the current Page.pdf() API for available options, because library releases can change. Print CSS applies by default; design the page’s @media print rules as part of the PDF output rather than expecting screen layout to carry over unchanged.

Generate a PDF buffer with Playwright

Playwright’s page.pdf() returns a PDF buffer and uses print CSS. This example saves the bytes to a file:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { chromium } from "playwright";
import { writeFile } from "node:fs/promises";

const browser = await chromium.launch();

try {
  const page = await browser.newPage();
  await page.goto("https://example.com", { waitUntil: "networkidle" });

  const pdf = await page.pdf({
    format: "A4",
    printBackground: true,
    margin: {
      top: "12mm",
      right: "12mm",
      bottom: "12mm",
      left: "12mm"
    }
  });

  await writeFile("page.pdf", pdf);
} finally {
  await browser.close();
}

The Page API includes options for paper format or dimensions, margins, and print-color behavior. If you need screen media rather than print media for the rendering, call Playwright’s media emulation API before generating the PDF. Check the current API reference for exact option names and supported values in the installed release.

Both Puppeteer and Playwright APIs operate on automated browser pages, not on the window object in an ordinary visitor’s browser tab. They are appropriate when your application controls the browser process and needs a PDF file or buffer, not as a way to bypass a visitor’s print dialog from front-end JavaScript.

Choose output settings and validate the result

Whether you use a print dialog or automation, HTML pages rarely translate to paper without layout decisions. Set page size and margins to suit the audience, and use print CSS to make content paginate sensibly. For automated runs, the PDF API can set several of these values directly; for a visitor-initiated print, browser and user settings still play a role.

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
  • Whole page or one element: use window.print() for the current document; use html2pdf.js to target an element; use automation when a controlled browser should render the page to a file or buffer.
  • Images and fonts: wait until content is ready before capture. Puppeteer waits for fonts by default during PDF generation, but your application may need to wait for lazy-loaded images or other asynchronous content.
  • Long tables and page breaks: review several pages of output, not just the first page. Adjust print CSS and test how the target browser handles breaks.
  • Color: background colors and images may require print-specific CSS or an API option, and the user’s print settings may also affect the result.
  • Quality and cost: no like-for-like speed, file-size, or accuracy benchmark establishes one method as universally best. Test representative pages in the actual browser or deployment environment.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common PDF export problems

The button opens a dialog instead of downloading a file

That is the expected behavior of window.print(). The API requests printing; it does not silently select a PDF destination. If a programmatic file or buffer is required, use an automated browser. If the user should download from the client, consider html2pdf.js and assess its output limitations.

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.

The printed PDF includes navigation or buttons

Add print-specific rules in @media print to hide elements such as navigation, footers, and controls. Preview the document in the print dialog and adjust the styles rather than assuming screen CSS will produce an appropriate page.

The automated PDF is missing content

The page may still be rendering when PDF generation begins. In automation, wait for the specific element or application state that indicates the content is ready. For pages with lazy-loaded images, ensure those images have loaded before output. Network-idle waits are not a universal readiness check.

The PDF layout differs from the screen

Print media is used by default for Puppeteer and Playwright PDF output. Add or refine print CSS; if screen media is intentionally required in Playwright, emulate it before calling page.pdf(). For the visitor print route, remember that print-dialog options can affect the final result.

html2pdf.js output has blurry text, large files, or blank pages

Its image-based pipeline explains why text is not selectable or searchable and why files can grow. A blank result can occur when content exceeds canvas dimensions; test shorter sections or another generation route. Increasing render scale may affect sharpness and resource use, so validate it against realistic documents.

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 the job is to capture a clean webpage rather than build a custom HTML-to-PDF workflow, ScreenshotNeo is a website screenshot API and MCP server. Its API can return a screenshot or PDF; the example below saves a WebP screenshot. Use the documentation for the supported PDF request parameters rather than guessing them. The API also accepts parameter names used by other screenshot APIs, which can make migration easier.

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

See the ScreenshotNeo documentation for request options. Cookie and consent banners, newsletter popups, and chat widgets can be removed before capture, with each cleanup step optional. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers report the page verdict and billing status. An MCP server provides screenshot tools for AI agents, including 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. Sign up for ScreenshotNeo’s free plan.

Frequently Asked Questions

Can browser JavaScript save a PDF without opening a dialog?

Not with window.print(); it opens the print dialog. For an automated file or buffer, generate the PDF through a browser automation process such as Puppeteer or Playwright.

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

Can I export only part of a page?

Yes. html2pdf.js can start from a selected element, while automated browser workflows can prepare the page or use print CSS to limit what appears.

Will the PDF text be searchable?

That depends on the method. html2pdf.js documents an image-based output where text is not selectable or searchable; do not assume the same limitation applies to browser print or automated-browser PDFs.

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.