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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

In an active WebdriverIO session, save the current page as a PDF with await browser.savePDF('./output.pdf', options). The path must end in .pdf; WebdriverIO writes the file and returns a Buffer. The API supports orientation, scale, backgrounds, page dimensions, margins, shrink-to-fit, and page ranges. See the official savePDF documentation for the version-specific details.

Use browser.savePDF() for the current WebdriverIO page

savePDF prints the current browsing context, so navigate and wait for the content you need before calling it. A minimal test looks like this:

describe('PDF export', () => {
  it('saves the current page', async () => {
    await browser.url('https://example.com');
    await browser.savePDF('./artifacts/example.pdf');
  });
});

The destination is resolved relative to the process execution directory. Create the destination directory first and make sure the test process has write permission. The method returns a Buffer, which is useful when you also need to inspect, upload, or store the generated bytes.

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

A complete example with print options

import fs from 'node:fs/promises';

describe('Invoice PDF', () => {
  it('exports a paginated invoice', async () => {
    await browser.url('https://example.com/invoice/123');
    await $('main').waitForDisplayed();

    await fs.mkdir('./artifacts', { recursive: true });

    const pdf = await browser.savePDF('./artifacts/invoice.pdf', {
      orientation: 'portrait',
      scale: 1,
      background: true,
      width: 8.27,
      height: 11.69,
      top: 0.4,
      bottom: 0.4,
      left: 0.4,
      right: 0.4,
      shrinkToFit: true,
      pageRanges: '1-3'
    });

    console.log(`Generated ${pdf.length} bytes`);
  });
});

The option names above are the documented WebdriverIO settings. Select values for your layout rather than treating these numbers as universal defaults. If your installed WebdriverIO release uses a slightly different type definition, follow that release’s API reference.

#1 Best Overall
Epson EcoTank ET-2800 Wireless Color All-in-One Supertank Printer - Black
  • INNOVATIVE CARTRIDGE-FREE PRINTING — No more dealing with lots of tiny ink cartridges; With this wireless document and photo printer each ink bottle set is equivalent to about 90 individual cartridges²
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; When you choose this combination printer, scanner and copier you can print up to 4,500 pages black/7,500 color³
  • COLOR PRINTING — Up to 2 years of ink in the box4 (and with every replacement ink set) for fewer out-of-ink frustrations
  • ZERO CARTRIDGE WASTE — By using an Epson EcoTank printer you can help reduce the amount of cartridge waste ending up in landfills
  • HOME PRINTER DESIGNED FOR RELIABILITY — The Epson EcoTank ET-2800 All-in-One Supertank Color Printer creates vivid, detailed prints and documents thanks to Micro Piezo Heat-Free Technology; Fire off 10 ISO pages per minute1 to easily finish large jobs

Common options and when to use them

Option What it controls Typical reason to change it
orientation Portrait or landscape page orientation Use landscape for wide tables or dashboards.
scale Print scaling Reduce scale when content is clipped; increase only when the layout has spare room.
background Whether page background colors and graphics are printed Enable it for branded invoices or colored charts.
width, height Printed page dimensions Match a paper format or a custom document size.
top, bottom, left, right Page padding/margins Reserve room for readable text or a binding edge.
shrinkToFit Whether the layout is reduced to fit the printable area Prevent a wide element from running off the page.
pageRanges Pages included in the output Export only selected pages, such as 1-3.

Dimensions and margin units are interpreted by the WebdriverIO print implementation. Check the API page linked above for the exact type and unit expectations of your release, then verify the resulting PDF visually.

Make the capture deterministic before printing

A PDF represents the page at the moment the browser prints it. Navigation finishing does not necessarily mean that client-side data, fonts, images, or a chart has rendered.

Wait for the content that matters

await browser.url('https://example.com/report');
await $('#report-ready').waitForDisplayed({ timeout: 15000 });
await browser.savePDF('./artifacts/report.pdf', { background: true });

Prefer a meaningful application signal such as a visible report container or a “ready” marker. A fixed sleep can be useful for a known animation, but it is less reliable when network or server timing changes. If the page has lazy content, scroll it into view before printing and wait for the relevant images or sections.

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

Control the print layout in CSS

Web pages can define print-specific behavior with @media print and @page. Hide navigation, avoid splitting a card, and set page margins in the application stylesheet:

@media print {
  .site-nav, .cookie-banner, .screen-only { display: none !important; }
  .invoice-line, .report-card { break-inside: avoid; }
}

@page {
  size: A4 portrait;
  margin: 12mm;
}

These rules belong to the page being printed; WebdriverIO’s options do not replace application print CSS. Browser print engines can paginate flex and grid layouts differently from a screen view, so inspect headings, tables, images, and links across page breaks.

Rank #2
Sale
Epson EcoTank Photo ET-8550 Wireless Wide-Format All-in-One Tank Printer
  • CARTRIDGE-FREE PRINTING — Print lab-quality photos, graphics and creative projects; Get vibrant colors and sharp text with Epson's high-accuracy printhead and Claria ET Premium 6-color inks
  • INK BOTTLES — Save on photos1 and creative projects with affordable in-house printing; All-in-one printer allows you to print 4" x 6" photos for about 4 cents each vs. 40 cents with traditional ink cartridges1
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; Printer, scanner and copier lets you print up to 6,200 color pages³
  • PRINT FOR LONGER — Up to 2 years of ink in the box² (and with every replacement ink set) for fewer out-of-ink frustrations with this wireless printer
  • ZERO CARTRIDGE WASTE — Epson EcoTank printer helps reduce the amount of cartridge waste ending up in landfills; Cartridge-free printer uses high-yield ink bottles; Each replacement ink bottle set is equivalent to about 100 individual ink cartridges⁴

Alternative: browser.printPage() through WebDriver

WebdriverIO also documents browser.printPage(), a WebDriver protocol command that returns a base64-encoded paginated PDF representation instead of directly writing a file. The surfaced WebdriverIO protocol documentation notes that Chrome currently supports this command only in headless mode; confirm support for the browser and driver versions in your project before choosing it. Read the WebDriver command documentation.

const encoded = await browser.printPage({
  orientation: 'portrait',
  scale: 1,
  background: true
});

const bytes = Buffer.from(encoded, 'base64');
await fs.writeFile('./artifacts/page.pdf', bytes);

Use this route when you specifically need the protocol response for another service. If you simply want a file from an existing WebdriverIO session, savePDF is the clearer API.

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

Chrome Headless without a WebdriverIO session

For a one-off URL, Chrome’s command-line headless mode can print directly to a PDF:

google-chrome --headless --print-to-pdf=output.pdf https://example.com

Chrome documents --no-pdf-header-footer to remove its default header and footer, and --timeout to set the maximum wait before capture:

google-chrome 
  --headless 
  --no-pdf-header-footer 
  --timeout=10000 
  --print-to-pdf=output.pdf 
  https://example.com

This is a browser CLI, not a WebdriverIO call. It does not reuse cookies, authenticated state, or in-test DOM changes unless you configure Chrome separately. See the Chrome Headless CLI documentation for current flag behavior.

Rank #3
HP Smart Tank 5000 Wireless All-in-One Ink Tank Printer, Scanner, Copier with 2 Years of Ink Included, Best-for-Home, Cartridge-Free, Refillable and AI-Enabled. (5D1B6A)
  • SET IT UP ONCE AND PRINT WITH CONFIDENCE. No complicated maintenance. Just easy, reliable printing you can count on.
  • INK FOR YEARS. NOT MONTHS. Up to 2 years of ink included. Get thousands of pages of cartridge-free printing. More pages, less hassle
  • KEEPS PRINTING WELL AFTER COMPETITORS HAVE QUIT. No complex maintenance. Sharper text, richer colors.[2] Only with HP Smart Tank
  • PREMIUM SUPPORT - Strong technical expertise to solve issues faster
  • THE LAST PRINTER YOU'LL EVER NEED. Enjoy years of refillable, cartridge-free printing.

Choosing the right route

Situation Best starting point Why
The page is already open in WebdriverIO and you need a file browser.savePDF() One call, documented layout options, and a returned Buffer.
You need a WebDriver protocol response browser.printPage() Returns base64 PDF data for your own storage pipeline; Chrome support is headless-only according to the surfaced documentation.
You have a public URL and no test session Chrome Headless CLI Simple command-line capture with documented timeout and header/footer flags.
You need repeatable URL capture without maintaining browsers ScreenshotNeo Hosted screenshot/PDF API with cleanup, billing verdicts, and an MCP server.

Or skip the browser setup: ScreenshotNeo

If your input is a URL rather than an already-authenticated WebdriverIO page, ScreenshotNeo provides a single HTTP request for a PDF or image. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.

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

cURL

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

Python

import requests

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

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}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const body = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', body));

The ScreenshotNeo documentation lists PDF parameters and the rest of its 63 options, including full-page lazy-image loading, CSS-selector element capture, dark mode, 12 device presets, custom viewports, retina scale, paper size, margins, landscape mode, page ranges, custom CSS and JavaScript, click-before-capture, selector or network-idle waits, request and resource blocking, headers, cookies, user agents, Authorization, timezone, geolocation, transparent backgrounds, resizing, configurable-TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage data, and an OpenAPI specification. Parameter names used by other screenshot APIs are also accepted, which can simplify migration.

It also offers an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. Pricing is Free for 1,000 shots per month with no card, then Starter $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 included on every plan. Create a free ScreenshotNeo account to start with 1,000 shots a month and no card.

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

Troubleshooting WebdriverIO PDF exports

“The file is empty or missing”

  • Confirm the path ends in .pdf.
  • Check the process working directory and create the parent folder with fs.mkdir(..., { recursive: true }).
  • Verify that the runner user can write to that location.
  • Log the returned buffer length and fail the test if it is unexpectedly small.

The PDF shows a loading skeleton

Wait for a page-specific ready element, data table, or image rather than only waiting for navigation. For animated interfaces, wait until the animation completes or disable animation in print CSS.

Colors or logos are missing

Set background: true and ensure the page’s print stylesheet does not remove the artwork. Some sites intentionally use different print colors.

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

Wide content is clipped

Try landscape orientation, a smaller scale, wider page dimensions, or shrinkToFit: true. Also inspect horizontal overflow in @media print; a fixed-width table may need a print-specific layout.

Rank #4
NDYIN Portable Printers Wireless for Travel, N80 Bluetooth Thermal Printer
  • Wireless Bluetooth Printer: Portable thermal printer compatible with iPhone, Android phones, iPad and tablet computers via Bluetooth. For smartphones, please download the "Nada Print" App. You can also connect to laptops and computers for printing using a USB-C cable. (Note: Laptops and computers can only be connected via USB and require the installation of a driver first. Bluetooth connection is not supported.)
  • No-ink printing: Only supports US Letter and A4 size thermal paper.(Doesn't support regular paper) The no-ink portable thermal printer uses direct thermal technology, requiring no ink, toner or ribbons, making it environmentally friendly, cost-effective and time-saving. The thermal printer package comes with a roll of US Letter thermal printing paper. Note: When installing the paper, remember to switch the paper size switch on APP
  • Clear Print: NDYIN N80 portable thermal printer adopts high-definition printing technology, with a 203DPI resolution to provide you with clear printing results. This mobile printer is compatible with roll paper, folded paper and tattoo transfer paper, supporting printing from your mobile phone PDF, Word, pictures and web pages anytime and anywhere. It is recommended to use our NDYIN thermal paper to achieve good printing quality
  • Portable wireless printer for travel: The thermal printer is equipped with a built-in 1500mAh rechargeable battery, which can print 160 sheets of 8.5" x 11" thermal paper after being fully charged. It weighs only 1.5 pounds and is compact in size. This ink-free portable printer can be easily carried in a backpack or briefcase! It is perfect for business travel, cars, small offices, construction sites, schools and homes. You can print documents, contracts, invoices and boarding passes anytime and anywhere
  • The N80 thermal printer has a wide range of uses. The package includes the N80 printer, a roll of US Letter paper(7m/roll), a user manual, a guide card, a type-C soft cable and a type C adapter. Note: The charging adapter is not included. Special thermal paper is required for use; ordinary paper cannot be used. This ink-free portable thermal printer is suitable for various scenarios such as home, school, travel, office, and outdoor, meeting the printing needs of different groups of people. This tattoo template printer is also compatible with tattoo transfer paper, making it an ideal choice for tattoo art

Page breaks split cards or rows

Add print CSS such as break-inside: avoid to the component, and test with realistic content lengths. A rule cannot always prevent a single item taller than one page from splitting.

printPage fails in headed Chrome

The surfaced WebDriver documentation identifies Chrome support as headless-only. Run the session in headless mode or use savePDF instead, then verify compatibility with the exact Chrome, driver, and WebdriverIO versions you deploy.

The PDF differs between machines

Pin browser and driver versions where possible, use the same fonts and locale, and set viewport, timezone, and authentication state explicitly. Rendering can change with installed fonts, responsive breakpoints, and asynchronous data.

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

Reliability and performance checklist

  • Use a dedicated output directory and unique filenames for parallel workers.
  • Wait on semantic readiness signals, not a single arbitrary delay.
  • Keep PDFs as test artifacts when diagnosing failures; compare page count and file size as smoke checks, then use visual review for layout regressions.
  • Close or reset sessions after capture so parallel tests do not share cookies or tabs accidentally.
  • For large reports, limit pageRanges when appropriate and avoid loading unrelated heavy resources in the page.
  • Remember that a PDF is paginated output: responsive breakpoints, print CSS, fonts, and page-break rules matter as much as the screen layout.

Security and data handling

Keep authenticated URLs, cookies, and generated PDFs out of source control and ordinary logs. Use environment variables or your CI secret store for credentials. If you switch from an in-process WebdriverIO browser to a hosted URL API, review what data the page contains and whether sending that URL to an external service is acceptable for your project.

FAQ

Does savePDF print only the visible viewport?

It prints the current browsing context as paginated output. The resulting pages follow print layout rules; inspect the PDF rather than assuming a screen-sized crop.

Can I save the returned buffer somewhere other than disk?

Yes. The documented method returns a Buffer, so you can upload it, hash it, or pass it to another Node.js API in addition to, or instead of, retaining the file.

Should I use WebdriverIO or Chrome’s CLI for authenticated pages?

Use the existing WebdriverIO session when the page depends on login state, test data, or actions performed in the browser. Chrome’s CLI is most convenient for a standalone URL.

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

Quick Recap

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.