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

How to Convert HTML Invoices to PDF in Bulk

Render each HTML invoice as a separate PDF job, validate fonts and page layout, and log failures so you can retry only the invoices that need attention.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Convert each invoice as its own PDF job, using a browser renderer such as Puppeteer or Playwright when you need modern HTML and CSS support. Wait for fonts and assets, apply explicit print settings, save to a sanitized, deterministic filename, and log each result. Test representative invoices before scaling up: there is no universal safe concurrency limit, and a successful render does not guarantee correct pagination.

Choose a rendering method

Pick the renderer based on the invoice templates, runtime, deployment needs, and privacy requirements—not on unverified speed or fidelity claims. The sources below document how each option works but do not establish a comparable benchmark.

As an Amazon Associate I earn from qualifying purchases.

Option Best fit Important consideration
Puppeteer with Chromium JavaScript services that can run Chromium and need browser-based PDF controls. page.pdf() renders using print CSS by default and waits for fonts by default. See Puppeteer’s PDF API and PDF generation guide.
Playwright with Chromium Projects already using Playwright or wanting its browser automation APIs. PDF export is Chromium-only; its API documents print-media behavior. See PDF export and print media.
wkhtmltopdf Environments where its Qt WebKit-based command-line conversion meets template requirements. It is an open-source headless HTML-to-PDF converter, but check its current maintenance, security posture, and compatibility before adopting it for a new deployment. See the project site.
Cloudflare Browser Run Teams considering hosted conversion of webpages or custom HTML. Review current data handling, limits, and pricing before sending invoice information. See Browser Run documentation.

Prepare a safe, repeatable batch

  1. Identify each invoice. Assign a stable invoice ID and sanitize it before using it in a filename. Avoid allowing raw customer-supplied text to become a filesystem path.
  2. Render one invoice per job. Treat every invoice as an independent success or failure so a single bad page does not obscure other results.
  3. Make assets available deliberately. Ensure the HTML can load its required stylesheets, logos, and other assets in the rendering environment. Wait for the page and fonts to finish before producing the PDF. Puppeteer’s documented PDF generation waits for fonts by default.
  4. Set print options explicitly. Choose paper format, margins, backgrounds, and headers or footers to match the invoice. Browser PDF generation uses print CSS by default in Puppeteer; verify how your template’s print styles affect the result.
  5. Write to a deterministic destination. Use a predictable mapping such as invoice-INV-1042.pdf, and ensure duplicate IDs cannot silently overwrite another invoice.
  6. Record each outcome. Log the invoice ID, output path, and success or failure. Check that expected files exist and are non-empty; retry failed jobs individually.

Generate PDFs with Puppeteer

The following Node.js example reads a directory of HTML files, opens each file in Chromium, waits for fonts, writes one PDF per input, and reports failures without stopping the rest of the batch. It assumes the invoice HTML and its local assets are arranged so relative paths resolve from the file. Install Puppeteer with npm install puppeteer; it manages a compatible browser installation for its standard setup.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Save as batch-invoices.js and run node batch-invoices.js ./invoices ./pdfs. Input filenames are reduced to safe basename characters before they are used for output names.

#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 fs = require('node:fs/promises');
const path = require('node:path');
const puppeteer = require('puppeteer');

function safeStem(filename) {
  return path.basename(filename, path.extname(filename))
    .replace(/[^a-zA-Z0-9_-]/g, '_');
}

async function main() {
  const inputDir = path.resolve(process.argv[2] || './invoices');
  const outputDir = path.resolve(process.argv[3] || './pdfs');
  await fs.mkdir(outputDir, { recursive: true });

  const files = (await fs.readdir(inputDir))
    .filter(name => name.toLowerCase().endsWith('.html'))
    .sort();
  const browser = await puppeteer.launch({ headless: true });
  const results = [];

  try {
    for (const filename of files) {
      const output = path.join(outputDir, `${safeStem(filename)}.pdf`);
      const page = await browser.newPage();
      try {
        await page.goto(`file://${path.join(inputDir, filename)}`, {
          waitUntil: 'networkidle0',
          timeout: 60000
        });
        await page.evaluate(() => document.fonts.ready);
        await page.pdf({
          path: output,
          format: 'A4',
          printBackground: true,
          preferCSSPageSize: true
        });
        const stat = await fs.stat(output);
        if (stat.size === 0) throw new Error('PDF output is empty');
        results.push({ invoice: filename, status: 'ok', output });
      } catch (error) {
        results.push({ invoice: filename, status: 'failed', error: error.message });
        await fs.rm(output, { force: true });
      } finally {
        await page.close();
      }
    }
  } finally {
    await browser.close();
  }

  for (const result of results) console.log(JSON.stringify(result));
  if (results.some(result => result.status === 'failed')) process.exitCode = 1;
}

main().catch(error => {
  console.error(error);
  process.exitCode = 1;
});

networkidle0 waits for network activity to quiet, which may be unsuitable for pages that keep connections open or load assets continuously. In that case, wait for a specific invoice-ready selector or a known completion condition instead, and retain the font wait. If invoice HTML is generated from records rather than stored as files, write or serve each invoice in a controlled way and navigate to its URL; do not concatenate multiple invoices into one page if each needs its own PDF.

Test layout before processing the full set

Render a small but representative sample, including cases that exercise different content lengths and assets. Inspect the PDFs themselves, not just the renderer’s success status.

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)
  • Short and long invoices, including line-item tables that span pages.
  • Logos and other required images, plus slow or unavailable assets.
  • Non-ASCII names, addresses, currency symbols, and other text used by your customers.
  • Page breaks, repeated table headers where required, totals, margins, and text legibility.
  • The output file’s existence, non-zero size, and correct mapping to its invoice ID.

PDF support does not ensure every invoice stylesheet paginates correctly. Fix print CSS or renderer-specific settings when a table splits badly, totals become detached, or content is clipped.

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

Batch reliability, performance, and cost

Do not assume a universal batch rate or safe concurrency number. Measure throughput and memory on the actual host with the actual templates and assets, then choose concurrency from those observations. Browser processes consume resources; increasing parallel jobs may reduce per-job latency while raising memory pressure or causing failures.

Rank #3
Sale
Epson Workforce ES-400 II High-Speed Color Duplex Desktop Document Scanner | For Computers including PC and Mac with Auto Document Feeder and Image Adjustment Tools
  • FAST DOCUMENT SCANNING — Document scanner with feeder allows you to speed through stacks with a 50-sheet Auto Document Feeder (ADF); Efficient office scanner to help you scan more productively
  • INTUITIVE, HIGH-SPEED SOFTWARE — Quickly scan with this desktop document scanner; Epson ScanSmart Software lets you easily preview scans, email files, upload to the cloud, and more; Plus, automatic file naming saves even more time
  • SEAMLESS INTEGRATION — Easily incorporate your data into most document management software with the included TWAIN driver; Office document scanner integrates seamlessly with business workflows
  • EASY SHARING — Duplex scanner allows you to scan straight to email or popular cloud storage2 services like Dropbox, Evernote, Google Drive, and OneDrive for simple storage and sharing
  • SIMPLE FILE MANAGEMENT — Scanner allows the creation of searchable PDFs with Optical Character Recognition (OCR) and convert scans to editable Word or Excel files effortlessly; Designed for home and office document scanning
  • Start with sequential jobs, as in the example, and record elapsed time, failures, and resource use.
  • Increase concurrency gradually only after measuring the target environment; keep each invoice’s output and error independently attributable.
  • Retry only failed invoices, rather than restarting a completed batch. Use bounded retries for transient asset or browser failures.
  • For hosted rendering, check the provider’s current limits, pricing, and handling of invoice data before sending sensitive information.
  • For self-hosted rendering, account for browser installation, updates, and security maintenance as part of deployment.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failures

PDF is missing or zero bytes

Check that the renderer reached the invoice page, that the output directory is writable, and that the PDF call completed without an exception. Remove partial files on failure and record the invoice ID and error for a targeted retry.

Fonts or images are absent

Confirm that asset URLs resolve from the browser process and that local files are accessible at the paths used by the HTML. Wait for fonts and any application-specific asset-ready signal before printing; remote assets may fail or load slowly.

Rank #4
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

Invoice content is clipped or paginated badly

Review print styles, paper size, margins, and page-break rules. Test invoices with long tables and totals near a page boundary. A successful browser PDF operation does not validate the intended layout.

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

The batch stalls while waiting for the page

A page with persistent network activity may never satisfy a network-idle wait. Prefer an explicit selector or application-ready condition when available, and apply a finite timeout so one invoice cannot block the entire run.

Best Value
Sale
ScanSnap iX2500 Wireless or USB High-Speed Document Scanner, Black
  • OUR MOST ADVANCED SCANSNAP. Large touchscreen, fast 45ppm double-sided scanning, 100-sheet document feeder, Wi-Fi and USB connectivity, automatic optimizations, and support for cloud services. Upgraded replacement for the discontinued iX1600
  • CUSTOMIZABLE. SHARABLE. Select personalized profiles from the touchscreen. Send to PC, Mac, mobile devices, and clouds. QUICK MENU lets you quickly scan-drag-drop to your favorite computer apps
  • STABLE WIRELESS OR USB CONNECTION. Built-in Wi-Fi 6 for the fastest and most secure scanning. Connect to smart devices or cloud services without a computer. USB-C connection also available
  • PHOTO AND DOCUMENT ORGANIZATION MADE EFFORTLESS. Easily manage, edit, and use scanned data from documents, receipts, photos, and business cards. Automatically optimize, name, and sort files
  • AVOIDS PAPER JAMS AND DAMAGE. Features a brake roller system to feed paper smoothly, a multi-feed sensor that detects pages stuck together, and skew detection to prevent paper damage and data loss

Or skip the browser setup

ScreenshotNeo can return a PDF from a single GET request, including PDF paper-size and page-range options. For a simple webpage capture, the call looks like this (the API key is available from your account; see the API documentation):

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

For invoice PDFs, request PDF output and set the relevant PDF options as documented, then use the invoice URL in place of the example URL. ScreenshotNeo accepts a URL for the capture; assess whether hosting invoice pages and sending them to a hosted service fits your privacy and data-handling requirements.

  • Cookie and consent banners, newsletter popups, and chat widgets are removed before the shot; each cleanup step can be turned off.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; responses report the page verdict and billing status in headers.
  • An 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 with no card; paid plans start at $5 for 3,000 shots. Every feature is on every plan.

Sign up for ScreenshotNeo’s free plan for 1,000 shots a month with no card.

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.

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.

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. 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
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver 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.