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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To convert a list of URLs into PDFs with Puppeteer, loop through the URLs, navigate a page to each one with page.goto(), and save the current page with page.pdf() to a unique file path. Puppeteer exports one page per call; looping and naming files are your application code, not a built-in multi-URL PDF operation.

Convert each URL into its own PDF

Install Puppeteer in a Node.js project, then run a script that opens the URLs sequentially. Each address should include a scheme such as https://. The example uses networkidle2, as in Puppeteer’s PDF guide, but that wait condition does not guarantee that every site’s dynamic content is ready. The HTTP status check and output naming are practical safeguards in this script.

  1. Create a project and install Puppeteer: npm install puppeteer.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  2. Save the following as convert.mjs in the project directory:

    #1 Best Overall
    Brother DCP-L2640DW Wireless Compact Monochrome Multi-Function Printer, Copy, Scan, Duplex, Mobile Printing
    • BEST FOR SMALL BUSINESSES – Engineered for extraordinary productivity, the Brother DCP-L2640DW Monochrome (Black & White) 3-in-1 combines laser printer, scanner, copier in one compact footprint and delivers high-quality black & white prints
    • FAST PRINTER WITH EFFICIENT SCANNING – Produces documents quickly with print speeds up to 36 ppm(2) and scan speeds up to 23.6/7.9 ipm(3) (black/color). A 50-page auto document feeder(4) allows for convenient, time saving multi-page scanning and copying
    • FLEXIBLE CONNECTION OPTIONS – Easily navigate the changing demands of your business with secure multi-device connectivity via built-in dual-band wireless (2.4GHz / 5GHz) and Ethernet. Or connect locally to a single computer via USB interface
    • BROTHER MOBILE CONNECT APP – Print, scan, and manage your wireless printer anytime, from almost anywhere from your mobile device. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(5)
    • CHOOSE BROTHER GENUINE TONER – When it’s time to replace your toner, be sure to choose Brother Genuine TN830 or TN830XL replacement toner. And with Refresh EZ Print Subscription Service, you’ll never worry about running out of toner again and you’ll enjoy savings of up to 50%(6) on Brother Genuine Toner. Get started with Refresh today with a Free Trial(1)
    import puppeteer from 'puppeteer';
    
    const urls = [
      'https://example.com',
      'https://example.org',
    ];
    
    const browser = await puppeteer.launch();
    try {
      const page = await browser.newPage();
    
      for (const [index, url] of urls.entries()) {
        try {
          const response = await page.goto(url, { waitUntil: 'networkidle2' });
          if (response && !response.ok()) {
            throw new Error(`HTTP ${response.status()}`);
          }
    
          await page.pdf({
            path: `output-${index + 1}.pdf`,
            format: 'A4',
          });
          console.log(`Saved output-${index + 1}.pdf from ${url}`);
        } catch (error) {
          console.error(`Could not convert ${url}:`, error);
        }
      }
    } finally {
      await browser.close();
    }
  3. Run it with node convert.mjs. Successful pages are saved as output-1.pdf, output-2.pdf, and so on in the current directory. The per-URL error handler allows later addresses to proceed if one navigation or export fails; the finally block closes the browser.

The official Puppeteer PDF-generation guide demonstrates the navigation-and-export primitives for an individual page. Its Page.pdf() API reference describes a PDF of the current page rendered with print CSS media.

Choose the PDF’s appearance

page.pdf() uses print media by default. Pages may have print-specific styles, so use that default when the document should follow the site’s print layout. To render screen styles instead, set the media type before exporting:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.emulateMediaType('screen');
await page.pdf({ path: 'screen-layout.pdf', format: 'A4' });

PDF output adjusts colors for printing by default. If exact colors matter, the Puppeteer documentation points to the CSS property -webkit-print-color-adjust. See the Page API for media emulation and the PDF guide for print behavior.

Paper, margins, backgrounds, and page ranges

The PDFOptions reference documents these controls:

For example, add margins and print backgrounds to the loop’s PDF call:

await page.pdf({
  path: `output-${index + 1}.pdf`,
  format: 'A4',
  margin: { top: '15mm', right: '12mm', bottom: '15mm', left: '12mm' },
  printBackground: true,
});

Choose settings based on the page’s print styling and the document you need. If the site defines its own paper size with CSS @page, consider preferCSSPageSize: true; otherwise Puppeteer fits that sizing to the selected format by default.

Separate PDFs or one combined document?

The direct workflow creates one PDF per URL: each page.pdf() call exports the currently loaded page, and a distinct path prevents later exports from overwriting earlier ones. The official Puppeteer documentation cited here does not describe a built-in operation to merge pages from multiple URLs into one PDF. If you need a single combined file, first generate the individual PDFs, then merge them as a separate step with a PDF library or tool chosen for your project.

Handle navigation and rendering failures

page.goto() resolves with the main resource response, or null in documented special cases. It can fail for an invalid URL, TLS/SSL error, unreachable server, timeout, or failed main resource. The example checks a non-null response for an unsuccessful HTTP status and reports the URL alongside an error, making failures easier to identify.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
HP LaserJet MFP M235sdw | Monochrome | Laser Printer | All-in-One | Duplex
  • FROM AMERICA'S MOST TRUSTED PRINTER BRAND – Perfect for offices printing, scanning and copying black & white brochures, business documents and presentations. Perfect for 1-5 people
  • FASTEST TWO-SIDED PRINTING IN ITS CLASS – Up to 28 black-and-white pages per minute single-sided. Quickly finish multipage print projects with the fastest in-class two-sided printing speed
  • DUAL-BAND WI-FI WITH SELF-RESET – Automatically detects and resolves connectivity issues
  • STRONG SECURITY – Built-in security features help protect your printer from potential attacks
  • PRINT FROM ANY DEVICE – Wireless printing from any mobile device, PC or tablet. Ethernet included. Works with Microsoft, Mac, AirPrint, Android, Chromebook and more.
  • One URL stops the run: Put the navigation and PDF export inside a per-URL try/catch, as shown, if you want the loop to continue after an individual failure.

  • The PDF misses late content: networkidle2 is a navigation wait choice, not a guarantee that asynchronous application work or lazy-loaded images have finished. Use a site-specific readiness condition, such as waiting for a known selector, when the page requires it; avoid relying on an arbitrary fixed sleep as a universal fix.

  • The URL cannot be reached: Confirm it is a full URL with a scheme and that the target is accessible from the machine running Puppeteer. Preserve the URL in logs to pinpoint the failing input.

  • A later PDF replaces an earlier one: Give every export a unique path. An index-based filename works for a fixed list; for repeated runs or changing input, use a naming scheme that also identifies the URL or run.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Browser cleanup is skipped after an error: Keep browser.close() in a finally block. Puppeteer’s getting started guide also closes the browser after its work.

    Best Value
    Sale
    HP LaserJet Pro 3101sdw | Monochrome | Laser Printer | All-in-One | Duplex
    • FROM AMERICA'S MOST TRUSTED PRINTER BRAND – Perfect for small teams printing professional-quality black-and-white documents and reports. Print speeds up to 35 ppm black.
    • PROFESSIONAL PRODUCTIVITY – Proficiency with every print—bring your business to life with toner designed for sharp, professional-quality prints
    • UPGRADED FEATURES – Fast printing, scanning and copying, auto 2-sided printing, a 250-sheet input tray and 50-sheet auto document feeder
    • AWARD-WINNING RELIABILITY – Performance you can count on page after page, and always ready for the high demands of business
    • WIRELESS PRINTING – Stay connected with our most dependable Wi-Fi, which looks for the best connection to stay online
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance and operating considerations

The sequential loop reuses one page and processes a single URL at a time, which keeps the flow straightforward and makes failures easy to associate with an input. Puppeteer can also hold multiple page instances in a browser, but how much parallelism is appropriate depends on the target sites and the available runtime; there is no universal concurrency level established by the API documentation. If you add parallel pages, give each its own navigation/export flow and unique output path, and monitor resource use.

PDF defaults can vary by Puppeteer version. The current official documentation reviewed for this guide identifies version 25.12.0 for its Page.pdf() and PDFOptions references; check the documentation matching your installed version before depending on a particular default.

Or skip the browser setup

ScreenshotNeo can return a PDF from one GET request, so you do not need to launch and manage Puppeteer for a capture. Its API can also render images, and the response indicates whether a page was clean or a failure/cache case.

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

For a PDF capture, use format=pdf with the documented endpoint and your key:

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

See the ScreenshotNeo API documentation for the accepted parameters. Cookie banners are accepted and removed before capture, along with known consent platforms, newsletter popups, and chat widgets; each of those cleanup steps can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

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

Frequently Asked Questions

Does Puppeteer have a built-in method to convert an entire URL list to one PDF?

No. The documented page.pdf() method exports the current page; a loop creates separate files, while combining them is a separate operation.

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.

Does networkidle2 guarantee that every page is ready for PDF capture?

No. It is a navigation wait condition, not a guarantee that site-specific asynchronous content has finished loading.

Quick Recap

Bestseller No. 2
Canon imageCLASS MF273dw - Monochrome Wireless Laser Printer, Multifunction With Scanner, Copier, Auto Document Feeder, With 1 Year Limited Warranty, 30 PPM, Black
Canon imageCLASS MF273dw - Monochrome Wireless Laser Printer, Multifunction With Scanner, Copier, Auto Document Feeder, With 1 Year Limited Warranty, 30 PPM, Black
Wireless 3-in-1: Print | Copy | Scan; Print up to 30 Pages Per Minute (BW, Letter); First Print Out in Approximately 5.3 Seconds (Letter)
SaleBestseller No. 3
HP Laserjet MFP M140w Wireless Black & White Printer, Print, scan, Copy, Fast speeds, Easy Setup, Mobile Printing, Best-for-Small Teams
HP Laserjet MFP M140w Wireless Black & White Printer, Print, scan, Copy, Fast speeds, Easy Setup, Mobile Printing, Best-for-Small Teams
FAST PRINT SPEEDS – Up to 21 black-and-white pages per minute single-sided; WIRELESS WITH SELF-RESET – Helps you stay connected
$169.00
Bestseller No. 4
HP LaserJet MFP M235sdw | Monochrome | Laser Printer | All-in-One | Duplex
HP LaserJet MFP M235sdw | Monochrome | Laser Printer | All-in-One | Duplex
DUAL-BAND WI-FI WITH SELF-RESET – Automatically detects and resolves connectivity issues
$179.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.