October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

Convert HTML to PDF with Clickable Links Using Playwright

Use Playwright’s Chromium-based page.pdf() to save HTML as a PDF, configure paper and print styling, and verify that links work in your target viewer.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Playwright’s page.pdf() with Chromium to create a PDF from a rendered page. The method can preserve link targets in the output, but the Playwright API reference does not guarantee that every PDF will contain working clickable link annotations. Keep links as ordinary HTML anchors, then test external and in-document links in the PDF viewer your readers will use.

Use Chromium and Playwright’s PDF API

Playwright’s Page API says that page.pdf() “generates a pdf of the page with print css media.” The method returns a PDF buffer; pass a path option to save it to a file. PDF export through Playwright is Chromium-only, even though Playwright supports other browser engines for automation generally. See the Page API, PDF Export tool documentation, and browser installation guide.

Install Playwright and its Chromium browser before running the example. Playwright documents installation commands for browser binaries and operating-system dependencies; use the commands appropriate to your environment and keep the package and browser installation aligned.

npm install playwright
npx playwright install --with-deps chromium

The following illustrative Node.js script navigates to a page, waits for network activity to settle, and writes an A4 PDF. Choose a wait condition appropriate to your site; applications that continue loading data after navigation may need an application-specific readiness check.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
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
const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  try {
    const page = await browser.newPage();
    await page.goto('https://example.com', { waitUntil: 'networkidle' });
    await page.pdf({
      path: 'page.pdf',
      format: 'A4',
      printBackground: true
    });
  } finally {
    await browser.close();
  }
})();

This pattern applies to a page you navigate to and to HTML you prepare in the browser. For supplied or dynamically generated HTML, wait until its content and fonts or images that matter to the document have rendered before calling page.pdf(). page.pdf() uses Chromium’s print rendering; its return value is a buffer if you want to handle or stream the PDF in your own code instead of saving it with path.

Keep links in the HTML and verify the PDF

Use standard anchor elements with valid href values, for example <a href="https://example.org">Reference</a>. The HTML Standard defines hyperlink semantics for anchors and their href attributes, but that alone does not establish how a PDF renderer will encode links. Playwright’s cited API reference does not expressly guarantee clickable annotations in every exported PDF.

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)
  1. Generate the PDF from the page with its normal anchor markup intact.
  2. Open the resulting file in the target PDF viewer and click at least one external link.
  3. Check in-document links too, such as links to a section or page fragment; confirm they navigate to the intended destination.
  4. If links are absent or inactive, compare the source HTML’s href values with the PDF behavior and test in the viewer your audience uses. Do not infer link preservation solely from valid HTML.

Choose print or screen styling deliberately

By default, PDF generation uses print CSS media. A page that looks right in a browser window can therefore produce a different PDF because its @media print rules hide, resize, or rearrange content. Inspect both @media print and @page rules when the exported layout differs from the screen.

If the intended output should use screen styling, emulate screen media before calling page.pdf():

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
  • STAY ORGANIZED – Easily convert your paper documents into digital formats like searchable PDF files, JPEGs, and more.Power Consumption : 2.5W or less (Energy Saving Mode: 0.7W). Suggested Daily Volume : 500 scans..Does it contain liquid: no
  • CONVENIENT AND PORTABLE –lightweight and small in size, you can take the scanner anywhere from home offices, classrooms, remote offices, and anywhere in between
  • HANDLES VARIOUS MEDIA TYPES – Digitize receipts, business cards, plastic or embossed cards, reports, legal documents, and more
  • FAST AND EFFICIENT – No technical hurdles or complicated setups here; easily scan both sides of a document at the same time, in color or black-and-white, at up to 12 pages-per-minute, and with a 20 sheet automatic feeder
  • BROAD COMPATIBILITY – Works with both Windows and Mac devices, be it laptop or computer
await page.emulateMedia({ media: 'screen' });
await page.pdf({ path: 'page.pdf', format: 'A4' });

Use this only when screen media is the desired rendering. It does not replace checking the actual PDF: paper dimensions, pagination, margins, and viewer behavior still affect the result.

Set paper size, margins, and other layout options

Playwright documents several options that control PDF layout. The format default is Letter, scale defaults to 1, and preferCSSPageSize, background printing, outline, and tagged output default to false. Check the current Page API reference for the full option types and current behavior.

Rank #4
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
  • IRIScan Express, portable scanner : scans color and black and white documents a blazing speed up to 8ppm simplex. Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
  • IRIScan Express mobile scanner is powered via an included micro USB 2. 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. USB cable provided. AC Adapter not provided and not needed.
  • IRIScan flatbed scanner uses a simplex scanning mode allows for quick and straightforward scanning of single-sided documents. IRIScan with its full portable features is the ideal document scanners for computers.
  • IRIScan document scanner : Versatile scanning capabilities, including scanning to Word, PDF, and Excel formats with companion software provided Readiris OCR
  • Receipt scanner and card scanner with Additional features include scanning business cards directly to Outlook, photo scanning, and receipt scanning for efficient document management
Option What it controls When to adjust it
format Named paper format; documented default is Letter. Set a format such as A4 when the document is intended for a different paper standard.
width, height Explicit page dimensions. Use when a named format is not the required page size.
margin Page margins. Adjust usable content area or avoid content being too close to page edges.
pageRanges Which pages to include. Export only selected pages when the full document is not needed.
scale Rendering scale; default is 1. Use cautiously to fit content; scaling changes the size of text and other page elements.
printBackground Whether to print background graphics; default is false. Set to true when background colors or images are part of the intended design.
preferCSSPageSize Whether CSS page size takes precedence; default is false. Set intentionally when the page’s @page CSS defines the desired paper size.
outline, tagged Optional PDF outline and tagged output; both default to false. Enable only when these document features are useful for your output and supported by the installed Playwright version.

For example, choose a paper format, include backgrounds, and set margins explicitly rather than relying on defaults:

await page.pdf({
  path: 'report.pdf',
  format: 'A4',
  margin: { top: '15mm', right: '12mm', bottom: '15mm', left: '12mm' },
  printBackground: true,
  preferCSSPageSize: false
});

If your stylesheet’s @page size should govern instead, set preferCSSPageSize: true and ensure the CSS rule expresses the size you want. Avoid setting conflicting paper dimensions in CSS and Playwright options without deciding which should win.

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.
Best Value
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
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use the Chrome CLI only when a script is unnecessary

Chrome also documents a headless --print-to-pdf command for saving a target page as PDF. Its headless command-line reference describes optional flags for omitting headers and footers and setting a capture timeout. That can suit a one-off command-line export, while Playwright is the appropriate route when your application needs browser automation, page preparation, or programmatic control of PDF options. See the Chrome headless command-line reference.

Troubleshoot common PDF problems

  • PDF export fails in Firefox or WebKit: Playwright’s documented PDF export capability is Chromium-only. Launch Chromium for page.pdf().
  • Content is missing or stale: The page may not have finished rendering when the PDF call ran. Wait for the content your application needs, using a condition suited to that page rather than assuming one navigation wait works for all sites.
  • The PDF differs from the browser view: Print CSS is the default. Inspect @media print and @page; emulate screen media only if screen styling is specifically intended.
  • Colors or background images are absent: Background printing defaults to off. Set printBackground: true if those elements belong in the document.
  • Paper size is unexpected: The documented format default is Letter. Set format or explicit dimensions, and decide whether CSS page size should take precedence through preferCSSPageSize.
  • Links are not clickable: Confirm the original anchors have correct href values, then inspect the exported PDF in the intended viewer. Valid source markup is not a guarantee that every renderer-viewer combination will expose active PDF links.
  • Chromium will not launch on a clean machine: Install the browser binary and required operating-system dependencies using Playwright’s browser installation guidance, then keep Playwright and its browser installation updated.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server; its PDF endpoint can capture a URL as a PDF in one request. The example saves the response body as a PDF:

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

See the ScreenshotNeo API documentation for request options. ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. For details, visit ScreenshotNeo.

Sign up free for 1,000 screenshots a month, with no card required.

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

Frequently Asked Questions

Can I use Playwright’s PDF export with Firefox or WebKit?

No. Playwright’s documented PDF export path requires Chromium.

Does Playwright guarantee that exported PDFs have clickable links?

The cited Page API does not state such a guarantee. Preserve normal anchor markup and check the generated file in your intended PDF viewer.

Quick Recap

Bestseller No. 3
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
BROAD COMPATIBILITY – Works with both Windows and Mac devices, be it laptop or computer; This product is not intended for scanning photographs on photo paper / photographic media
$184.00
Bestseller No. 4
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
Find our Software here : irislink.com/start; IRIScan Express is only compatible Windows platform and not macintosh
$129.00
Bestseller No. 5
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
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
$75.00

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.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
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.