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.

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

Short answer: render the complete document in one Puppeteer Page.pdf() call when you need continuous page numbers. Enable displayHeaderFooter, provide a headerTemplate or footerTemplate, insert Puppeteer’s pageNumber and totalPages classes, and reserve space with explicit margins. If PDFs already exist as separate files, merge their pages first (or otherwise stamp the assembled PDF) and create global numbering with a post-processing step; the counters from separate print jobs do not automatically continue after concatenation.

Choose the numbering architecture first

There are two different jobs that are often called “merging PDFs.” The correct implementation depends on which one you have.

Render all content together

If you can combine the source data or HTML into one document, let Puppeteer paginate that document once. The pageNumber and totalPages template classes then describe the pages in that single PDF operation. This is the simplest way to obtain a reliable document-wide counter.

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

Assemble PDFs that already exist

If chapters or reports were printed separately, each file had its own page sequence. Concatenating those files does not turn their independent counters into one global sequence. Use a PDF composition or stamping stage that knows the final page order and count, or regenerate the complete content in one Puppeteer operation. Validate the resulting file with representative inputs.

#1 Best Overall
Brother HL-L2405W Wireless Compact Monochrome Laser Printer with Mobile Printing, Black & White Output | Includes Refresh Subscription Trial(1), Works with Alexa
  • BEST FOR HOMES & HOME OFFICES – Engineered for consistent, premium print quality, the Brother HL-L2405W Monochrome (Black & White) Laser Printer delivers sharp, crisp prints at an affordable price. Prints one-sided documents at speeds up to 30ppm(2)
  • COMPACT, CONNECTED PRINTER – Flexible connection options make this an ideal printer for home use and at-home offices. Securely connect to multiple devices with built-in dual-band wireless (2.4GHz/5GHz) or locally to a single computer via USB interface
  • BROTHER MOBILE CONNECT APP – Manage your printer remotely and print from your mobile device anytime, from almost anywhere. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(3)
  • VERSATILE PAPER HANDLING – Enjoy seamless, reliable everyday printing with the 250-sheet paper tray(4) and a manual feed slot that enables printing on envelopes and specialty pape
  • BROTHER IS AT YOUR SIDE – Backed by Brother with a 1-year limited warranty and free online, call, or live chat support for the life of your printer

Requirements and project setup

  • Node.js with Puppeteer installed and a compatible Chromium/Chrome binary.
  • For page assembly, the pdf-lib package (or another PDF SDK that supports your required stamping features).
  • HTML print styles, a target paper size, and a clear header/footer layout.
  • Representative test files if your PDFs contain forms, encryption, bookmarks, unusual page boxes, or mixed dimensions.

The Puppeteer API documentation surfaced for this workflow is version 25.12.0. Match examples to the Puppeteer and browser versions installed in your project; API behavior and template restrictions can change between releases.

One-pass Puppeteer PDF with a custom header and page numbers

Puppeteer generates PDFs using the print CSS media type by default. Put print-specific rules in @media print. If your design intentionally depends on screen media, call page.emulateMediaType('screen') before page.pdf().

Complete runnable example

const puppeteer = require('puppeteer');
const fs = require('fs');

(async () => {
  const browser = await puppeteer.launch({
    headless: true
  });
  try {
    const page = await browser.newPage();
    await page.setContent(`
      <!doctype html>
      <html>
      <head>
        <meta charset="utf-8">
        <style>
          @page { size: Letter; }
          body { font-family: Arial, sans-serif; font-size: 11pt; }
          h1 { break-before: page; }
          h1:first-child { break-before: auto; }
          @media print {
            .avoid-break { break-inside: avoid; }
          }
        </style>
      </head>
      <body>
        <h1>Quarterly report</h1>
        <p>Replace this content with your complete, combined document.</p>
        <h1>Appendix</h1>
        <p class="avoid-break">Appendix material.</p>
      </body>
      </html>`, { waitUntil: 'networkidle0' });

    const pdf = await page.pdf({
      format: 'Letter',
      printBackground: true,
      displayHeaderFooter: true,
      headerTemplate: `
        <div style="width:100%; font-size:9px; text-align:center;">
          Quarterly report
        </div>`,
      footerTemplate: `
        <div style="width:100%; font-size:9px; text-align:center;">
          Page <span class="pageNumber"></span> of
          <span class="totalPages"></span>
        </div>`,
      margin: {
        top: '60px',
        bottom: '50px',
        left: '48px',
        right: '48px'
      }
    });

    fs.writeFileSync('report.pdf', pdf);
  } finally {
    await browser.close();
  }
})();

displayHeaderFooter is off unless you enable it. The special classes are injected by Puppeteer at print time; keep them in the header or footer template exactly as shown. Margins are not automatically reserved for custom content, so inspect the first and last lines on every page and increase the top or bottom margin if text overlaps.

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

Headers that vary by document data

Build the template string from trusted, escaped values such as a report title or revision. Keep the template self-contained and conservative: the cited API reference identifies the page-number classes but does not guarantee that arbitrary application CSS, external stylesheets, or remote assets will behave like the main document. Inline the small amount of styling needed for predictable output.

Rank #2
Canon imageCLASS LBP6030w - Monochrome Single-Function Wireless Compact Wireless Laser Printer, 1 Year Limited Warranty, 19 PPM, White - Print Only
  • FAST PRINT SPEEDS: Print up to 19 pages per minute.
  • COMPACT DESIGN: Space-saving, compact design fits anywhere in your home, school or small office.
  • WIRELESS CONNECTIVITY: Print from almost anywhere in your workspace using your compatible mobile device.
  • PAPER CAPACITY: Up to 150 sheets.
  • SUSTAINABILITY: Uses less than 2 watts in Energy Saver mode.

Combining existing PDFs with pdf-lib

pdf-lib documents a destination PDFDocument, loading source documents, copying selected pages, and adding those pages to the destination. The order in which you call addPage() determines the final order.

const fs = require('fs');
const { PDFDocument } = require('pdf-lib');

async function merge(paths, output) {
  const destination = await PDFDocument.create();

  for (const path of paths) {
    const sourceBytes = fs.readFileSync(path);
    const source = await PDFDocument.load(sourceBytes);
    const indices = source.getPageIndices();
    const copied = await destination.copyPages(source, indices);
    copied.forEach(page => destination.addPage(page));
  }

  fs.writeFileSync(output, await destination.save());
}

merge(['cover.pdf', 'chapter-1.pdf', 'chapter-2.pdf'], 'assembled.pdf')
  .catch(error => {
    console.error(error);
    process.exitCode = 1;
  });

This assembles pages; it does not prove that every advanced PDF feature survives unchanged. Test encrypted documents, AcroForm fields, bookmarks, annotations, embedded files, transparency, and unusual page dimensions using the exact package version you deploy.

How to create global numbers after assembly

Preferred option: regenerate as one document

When possible, combine the chapter data or HTML before calling page.pdf(). Puppeteer then knows the complete page count and can inject both counters in one operation. This also gives you one place to control print CSS, paper size, margins, and headers.

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.

Post-process the assembled file

When source PDFs cannot be regenerated, use a stamping-capable PDF library after merging. The stamping pass must iterate over the destination pages in their final order and draw the global number and any header. A commercial option such as PDFlib+PDI describes importing existing pages and adding headers, footers, stamps, or page numbers; evaluate licensing, deployment, and feature requirements independently.

Rank #3
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)

Do not attempt to calculate a global value by simply offsetting each source PDF’s existing footer unless you control every source page and know its final position. A source may have front matter, blank pages, or a different page range than expected.

Print settings that prevent layout defects

Reserve header and footer space

Set explicit margin.top and margin.bottom values. Render at the final paper size, then inspect pages containing long headings, tables, images, and footnotes. A header can collide with body text even when ordinary pages look correct.

Control media and page breaks

Because Page.pdf() uses print media, define print colors, visibility, and breaks deliberately. Use CSS break-before, break-after, and break-inside where supported by your browser version. Avoid assuming that a screen layout will paginate identically.

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

Wait for content

Use waitUntil: 'networkidle0' only when the page can become idle; applications with persistent connections may never satisfy it. Otherwise wait for a specific selector or an application-ready signal, and ensure fonts and images have finished loading before printing.

Rank #4
Brother HL-L2460DW Wireless Compact Monochrome Laser Printer with Duplex, Mobile Printing, Black & White Output | Includes Refresh Subscription Trial(1), Works with Alexa
  • BEST FOR HOME OFFICES & SMALL TEAMS – Engineered for consistent, premium print quality, the Brother HL-L2460DW Monochrome (Black & White) Laser Printer produces documents that are clear, crisp, and easy to review and share, all at an affordable price
  • COMPACT, CONNECTED, EXCEPTIONALLY EFFICIENT– Connect with built-in dual-band wireless (2.4GHz/5GHz), Ethernet, or to a single computer via USB interface. Prints at speeds up to 36ppm(2), plus automatic duplex printing saves time and reduces paper waste
  • BROTHER MOBILE CONNECT APP – Manage your wireless printer remotely and print from your mobile device anytime, from almost anywhere. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(3)
  • VERSATILE PAPER HANDLING – Tackle high-volume black & white printing with the 250-sheet capacity paper tray.(4) The manual feed slot enables printing on envelopes and specialty paper
  • BROTHER IS AT YOUR SIDE – Backed by Brother with a 1-year limited warranty and free online, call, or live chat support for the life of your printer

Decision table

Approach Best fit Numbering authority Main qualification
One Puppeteer render All content can be combined before printing Puppeteer’s single PDF operation Requires one HTML/content pipeline and controlled print CSS
Puppeteer renders plus pdf-lib assembly Existing PDFs must be ordered and combined A later stamping step, or source-local numbers only Page copying does not establish universal preservation of forms, encryption, bookmarks, or page boxes
Commercial import/stamping SDK Advanced import, stamping, or enterprise PDF requirements The SDK’s final-document pass Confirm licensing, support, and compatibility for your files
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

“Page 1 of 3” appears in every source file

That is expected when files were printed separately. The template counters are scoped to each print operation. Merge first and stamp the assembled document, or render all content together.

The header covers the first paragraph

Increase the top margin and reduce the header’s height. Repeat the inspection at the selected paper size; margins that work on Letter may not work on A4.

The footer is missing

Confirm displayHeaderFooter: true, that footerTemplate is non-empty, and that the bottom margin leaves room. Header/footer templates are separate from the document body.

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

Colors or responsive layout changed

Print media is the default. Add print rules, use printBackground: true when backgrounds are required, or call emulateMediaType('screen') before printing if screen styling is intentional.

Best Value
HP LaserJet M110w | Monochrome | Laser Printer
  • FROM AMERICA'S MOST TRUSTED PRINTER BRAND – Perfect for small teams printing professional-quality black & white documents and reports. Perfect for 1-3 people
  • WORLD'S SMALLEST LASER IN ITS CLASS – Precision laser printing that fits anywhere
  • FAST PRINT SPEEDS – Up to 21 black-and-white pages per minute single-sided
  • WIRELESS WITH SELF-RESET – Helps you stay connected
  • PRINT FROM ANY DEVICE – Wireless printing from any mobile device, PC or tablet. Works with Microsoft, Mac, AirPrint, Android, Chromebook and more

The script hangs while waiting

A page with analytics, WebSockets, or long polling may never become network-idle. Replace the idle wait with a deterministic selector or readiness flag, and set an application-level timeout so failed jobs terminate cleanly.

Pages, forms, or bookmarks changed after merging

Page-copy APIs show how to assemble pages but are not a blanket compatibility guarantee. Test the exact files and library versions. If preservation is mandatory, choose a tool whose documentation explicitly covers the required feature and verify the output.

Mixed page sizes look wrong

Inspect each source page’s dimensions after copying. Decide whether to preserve mixed sizes or normalize them in a controlled stamping or conversion pass; do not assume the destination will resize every page consistently.

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

Validation checklist for production

  1. Render a short file and a multi-section file with the final paper size.
  2. Verify the first, middle, and last page numbers against the assembled page count.
  3. Check headers and footers on pages with large tables, images, and manual breaks.
  4. Open the output in more than one PDF viewer.
  5. Test representative encrypted, form-enabled, bookmarked, and mixed-size inputs if those occur in production.
  6. Record Puppeteer, browser, pdf-lib, and stamping-library versions with the build.

Or skip the browser setup

If your goal is simply to capture a web page as an image or PDF rather than build a custom multi-source PDF pipeline, ScreenshotNeo provides a single API request. Its cleanup step accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be disabled. Bot checks, 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. It also offers an MCP server for Claude, Cursor, and other MCP clients.

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

See the ScreenshotNeo documentation for PDF parameters, page ranges, margins, headers, and other capture options. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.

Frequently Asked Questions

Can Puppeteer continue page numbers across two PDF files?

No. The documented template counters apply to the single PDF operation that is being printed. A later merge needs a final-document stamping pass or a one-pass render of all content.

Do I have to use pdf-lib to merge PDFs?

No. pdf-lib is a JavaScript option whose documented copyPages and addPage methods support assembly. Other PDF libraries or commercial SDKs may be appropriate when you need specialized stamping or feature preservation.

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

Why are explicit margins necessary?

Puppeteer does not set margins for you. Without enough top and bottom space, custom header or footer content can overlap the body.

Quick Recap

Bestseller No. 2
Canon imageCLASS LBP6030w - Monochrome Single-Function Wireless Compact Wireless Laser Printer, 1 Year Limited Warranty, 19 PPM, White - Print Only
Canon imageCLASS LBP6030w - Monochrome Single-Function Wireless Compact Wireless Laser Printer, 1 Year Limited Warranty, 19 PPM, White - Print Only
FAST PRINT SPEEDS: Print up to 19 pages per minute.; PAPER CAPACITY: Up to 150 sheets.; SUSTAINABILITY: Uses less than 2 watts in Energy Saver mode.
$134.99
Bestseller No. 5
HP LaserJet M110w | Monochrome | Laser Printer
HP LaserJet M110w | Monochrome | Laser Printer
WORLD'S SMALLEST LASER IN ITS CLASS – Precision laser printing that fits anywhere; FAST PRINT SPEEDS – Up to 21 black-and-white pages per minute single-sided

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.