October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober 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

How to Convert Web Pages to PDF with an API

Use a browser automation library or hosted endpoint to turn a web page into a PDF, with practical guidance on CSS media, page options, output handling, and deployment.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To convert a web page to PDF with an API, either render it in a browser automation library such as Puppeteer or Playwright and call its PDF method, or send a URL or HTML to a hosted conversion endpoint. Choose print or screen CSS deliberately, set the page format and margins, then decide how your application will receive and store the PDF.

Choose a browser library or a hosted API

With browser automation, your application opens the page in a browser engine and invokes its PDF method. This gives you control over navigation, rendering media, and supported PDF options, but you operate the browser workflow. Puppeteer and Playwright document this approach: Puppeteer Page.pdf() and Playwright Page documentation.

As an Amazon Associate I earn from qualifying purchases.

A hosted conversion API accepts an input such as a URL or HTML and returns a PDF according to that provider’s interface. One project reference documents separate HTML, URL, and file routes; these are examples of possible endpoint designs, not routes every service provides. See the Chromium PDF Service API reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Decision Browser automation Hosted conversion API
Input Navigate to a page or load supplied content, then call the library’s PDF method. Use the specific service’s documented input route, such as URL or HTML where supported.
Rendering controls Set media mode and supported PDF options in your code. Use only the options and response behavior documented by that provider.
Operations Your application runs and maintains the browser automation workflow. The service handles conversion requests; you still need to assess its terms and operational fit.
Security, quotas, price, reliability Depends on your deployment and configuration; the cited library references do not establish these for your application. Provider-specific; the endpoint reference does not establish commercial terms or service quality.

Compare the options against CSS fidelity, page-setting control, input type, output transport, deployment burden, access to authenticated pages, security needs, and the provider’s current price and quotas. The documentation linked here establishes browser PDF controls and example endpoint shapes, not vendor pricing, security guarantees, quotas, or reliability.

#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

Render with Puppeteer

Install Puppeteer in your Node.js project, launch its browser, navigate to the target, and call page.pdf(). The following example saves a US Letter PDF using print CSS:

import puppeteer from 'puppeteer';

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: 'Letter',
    printBackground: true,
    margin: { top: '0.5in', right: '0.5in', bottom: '0.5in', left: '0.5in' }
  });
} finally {
  await browser.close();
}

Adjust navigation readiness to the page you are capturing; waiting for network idle is not appropriate for every site, particularly pages with persistent network activity. The path option saves the file, while the PDF method also returns PDF bytes that your application can handle directly. Puppeteer documents a stream alternative as well. See Puppeteer PDFOptions and Page.createPDFStream().

Select print or screen styles

page.pdf() uses print CSS by default. This is usually appropriate for documents designed for paper, but it can omit or rearrange elements that appear on screen. To render screen styles instead, select that media type before generating the PDF:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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)
await page.emulateMediaType('screen');
const pdf = await page.pdf({ format: 'A4', printBackground: true });

Colors may be modified for printing by default. Puppeteer documents -webkit-print-color-adjust for forcing exact colors where the page’s styling requires it. Apply it in the page CSS only when preserving those colors is intentional.

Render with Playwright

Playwright also provides a page PDF method. This Node.js example creates a file with A4 dimensions and margins:

import { chromium } from 'playwright';

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,
    margin: { top: '12mm', right: '12mm', bottom: '12mm', left: '12mm' }
  });
} finally {
  await browser.close();
}

Playwright’s PDF output uses print CSS. To produce a PDF with screen media styles, set the page media before calling the PDF method:

Rank #3
Sale
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' });

Playwright documents paper formats and supports dimensions and margins with units. Consult the Page API reference for the exact option names supported by the version installed in your project.

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

Set the PDF output deliberately

Before deploying a conversion workflow, decide how the result should look and how your application will handle the bytes:

  • Page size: choose a named format such as Letter or A4, or use supported width and height values when you need a custom page size.
  • Margins: set explicit margins when content should not run to the paper edge. Use units accepted by the selected library.
  • Backgrounds and colors: enable background printing if the document relies on colored blocks or background images. Check print color adjustment if colors differ from the screen.
  • Scale: Puppeteer’s PDF options include scaling. Verify the installed version’s reference before depending on a specific option.
  • Headers and footers: Puppeteer documents header and footer display options and HTML templates. Confirm template behavior and supported markup in your version.
  • Output handling: save to a path, use returned bytes, or use a stream where the library supports it. Puppeteer documents Page.pdf() as returning PDF bytes and createPDFStream() as returning a readable stream.

Relative output paths in Puppeteer are resolved against the current working directory. Hosted APIs can differ in whether they return bytes, a URL, or another response; inspect the chosen provider’s documentation rather than assuming browser-library behavior applies.

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

Or skip the browser setup

ScreenshotNeo can return a PDF from one GET request. Its API accepts a URL; see the ScreenshotNeo API documentation for the PDF options and response details.

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

Use the appropriate documented PDF parameters for paper size, margins, landscape orientation, or page ranges when needed. ScreenshotNeo removes supported cookie and consent banners, newsletter popups, and chat widgets before capture; each cleanup step 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 includes tools for AI agents to take screenshots, get page information, and capture PDFs. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.

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

Create a free ScreenshotNeo account to use the monthly free allowance without a card.

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

Troubleshoot common conversion problems

  • The PDF has the wrong layout: check whether the library is rendering print or screen media. Print media is the default for both documented browser methods; select screen media before PDF generation if that is the intended design.
  • Background colors or images are missing: enable background printing in the PDF options and review print-specific CSS. Color adjustment may also affect printed colors.
  • Text or images are clipped: review page format, dimensions, margins, and scale. Check whether the page’s print styles set fixed widths or hide content.
  • Navigation hangs or times out: some pages maintain open network requests, so a network-idle wait may never be reached promptly. Choose a readiness condition that matches the page’s behavior and verify that the content is present before producing the PDF.
  • The PDF is not where expected: check the process working directory when using a relative Puppeteer path, or use an explicit absolute path.
  • A hosted API response differs from the expected file: check the provider’s route, request format, authentication requirements, and response documentation. Endpoint types and output handling are not uniform across services.

Plan for deployment, access, and cost

Self-hosted browser automation puts the browser workflow in your application’s operational boundary. Validate that your deployment can run the selected browser and has the fonts and execution resources your pages require; the cited browser references describe PDF APIs, not a specific cloud or serverless provider’s support.

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

For authenticated pages, a browser workflow can operate within an application-controlled session, but you must manage credentials and access safely. For a hosted converter, confirm whether its documented inputs can represent your authentication needs and review where page content is processed. The endpoint reference alone does not establish a service’s security guarantees.

For either approach, estimate conversion volume, output storage and transfer, and any browser runtime costs or API quotas. The technical references linked above do not establish hosted-provider pricing, limits, or service commitments, so verify current terms directly with the provider before choosing.

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

Frequently Asked Questions

Can I convert a page using screen CSS instead of print CSS?

Yes. Both Puppeteer and Playwright document selecting screen media before generating the PDF; the relevant code is shown above.

Can a hosted PDF API accept HTML rather than a URL?

Some do. The Chromium PDF Service reference documents separate HTML, URL, and file routes, but other APIs may expose different inputs.

Does a PDF method return a file or data?

It depends on the method and provider. Puppeteer documents a byte-array result from Page.pdf() and a readable stream from createPDFStream(); hosted API response formats are provider-specific.

Quick Recap

SaleBestseller 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
$153.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.

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

Leave a Reply

Your email address will not be published. Required fields are marked *

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair 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.