To save an authenticated page as a PDF with Playwright, first identify how the site authenticates you, establish that session in a browser context, navigate to the page, wait for the content you need, and call page.pdf(). Use httpCredentials for HTTP authentication; for a site login form, complete its login flow or reuse a previously saved Playwright storage state.
Choose the right authentication method
A password prompt can represent different mechanisms. Playwright needs the one the site actually uses; putting a website-form password into HTTP credentials will not log you in, and vice versa.
As an Amazon Associate I earn from qualifying purchases.
HTTP authentication
For HTTP authentication, provide the username and password when creating the browser context. The optional origin limits where Playwright sends the credentials. See the Browser API documentation for context options.
Application login form
For a normal sign-in page, use the site’s login flow to establish its session before navigating to the protected page. This may involve a form, redirects, multi-factor authentication, or a CAPTCHA; the exact steps depend on the site. Playwright’s authentication guide describes setting up authentication and saving browser storage state, and its APIRequestContext documentation covers API-based requests where a site supports that authentication route.
#1 Best Overall
- 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
Save a page protected by HTTP authentication
This runnable Node.js example reads credentials from environment variables, authenticates only to the specified origin, opens the page, and writes an A4 PDF:
import { chromium } from 'playwright';
const browser = await chromium.launch();
try {
const context = await browser.newContext({
httpCredentials: {
username: process.env.PAGE_USERNAME,
password: process.env.PAGE_PASSWORD,
origin: 'https://example.com',
},
});
const page = await context.newPage();
await page.goto('https://example.com/protected-page');
// Replace this with a condition that confirms the required content is ready.
await page.locator('main').waitFor({ state: 'visible' });
await page.pdf({ path: 'page.pdf', format: 'A4' });
} finally {
await browser.close();
}
Set PAGE_USERNAME and PAGE_PASSWORD in the environment before running the script. Replace both example URLs and the readiness selector with values for the site. Avoid placing real credentials in source code.
Rank #2
- 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)
Save a page protected by a login form
For a one-off capture, automate the site’s normal login flow, then verify that login succeeded before opening the target page. The selectors below are illustrative: use the actual accessible labels and URLs from the site.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
import { chromium } from 'playwright';
const browser = await chromium.launch();
try {
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://example.com/login');
await page.getByLabel('Email').fill(process.env.PAGE_USERNAME);
await page.getByLabel('Password').fill(process.env.PAGE_PASSWORD);
await page.getByRole('button', { name: 'Sign in' }).click();
// Confirm an authenticated state before attempting the protected page.
await page.getByRole('navigation', { name: 'Account' }).waitFor();
await page.goto('https://example.com/protected-page');
await page.locator('main').waitFor({ state: 'visible' });
await page.pdf({ path: 'page.pdf', format: 'A4' });
} finally {
await browser.close();
}
Replace the example login and account-navigation selectors with reliable indicators for the particular site. If sign-in requires MFA, CAPTCHA, or another interactive step, that requirement must be handled by the site’s supported authentication process; the example does not bypass it.
Rank #3
- 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
Reuse application login with storage state
For recurring runs, authenticate in a setup step, confirm the session is valid, and save Playwright’s storage state. Later runs can initialize a context from that state:
import { chromium } from 'playwright';
const browser = await chromium.launch();
try {
const context = await browser.newContext({
storageState: 'playwright/.auth/user.json',
});
const page = await context.newPage();
await page.goto('https://example.com/protected-page');
await page.locator('main').waitFor({ state: 'visible' });
await page.pdf({ path: 'page.pdf', format: 'A4' });
} finally {
await browser.close();
}
The file can contain cookies and headers that let someone act as the account. Keep it out of source control, do not print its contents in logs, and remove or refresh it when the session expires. Follow the storage-state workflow in Playwright’s authentication guide.
Rank #4
- 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
Control PDF appearance and readiness
Playwright’s Page API documents that page.pdf() generates a PDF using print CSS media by default. If you want the page’s screen styling instead, emulate screen media before generating the file:
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →await page.emulateMedia({ media: 'screen' });
await page.pdf({ path: 'page.pdf', format: 'A4' });
Navigation completing is not proof that the content you need has rendered. Wait for a meaningful site-specific condition, such as a visible content container or a heading unique to the protected page, before calling page.pdf(). The Page API lists PDF options such as page format; choose settings to suit the document rather than assuming every page prints correctly with defaults.
Best Value
- Scanner type: Document
- Connectivity technology: USB
- With Auto Scan Mode, the scanner automatically detects what you're scanning
- Digitize documents and images
Troubleshoot common failures
- The page shows a login prompt: Check whether the site uses HTTP authentication or a form-based session. Use context credentials for the former; complete the site’s login flow or load valid storage state for the latter.
- The script saves a login page instead of the target: Add an explicit authentication-success check before navigating to the protected URL. Check for redirects and confirm that saved state has not expired.
- The PDF is blank or missing content: Wait for the specific content needed, not just navigation. Pages may render data or images after the initial load.
- The PDF looks different from the browser: PDFs use print CSS media by default. Call
page.emulateMedia({ media: 'screen' })before export if screen styles are the intended output. - Credentials work on one host but not another: Check the credential
originand the URL’s scheme and host. Credentials scoped to one origin should not be assumed to apply to a different one. - A reused session stops working: The site may have expired or invalidated its cookies or session. Re-run the authentication setup and save fresh state; do not expose the state file while diagnosing the issue.
- The login flow cannot finish automatically: The site may require MFA, CAPTCHA, or an interactive challenge. Use the site’s permitted login process rather than assuming Playwright can complete every authentication flow unattended.
Or skip the browser setup
For a straightforward capture, ScreenshotNeo offers a screenshot API and MCP server. This one-call cURL example returns a PDF for the target URL; provide your API key and an authorized URL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/protected-page -d format=pdf -o page.pdf
See the ScreenshotNeo API documentation for request parameters and authentication options. ScreenshotNeo accepts cookie and consent banners like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000.
Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month without a card.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →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.




