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

To show “Page X of Y” in a Puppeteer PDF, pass displayHeaderFooter: true to the actual page.pdf() call and put pageNumber and totalPages in the header or footer template. Puppeteer documents displayHeaderFooter as false by default, so a template alone may not appear. Use inline CSS in the template and reserve space with PDF margins; Tailwind styles from the page are not guaranteed to apply inside it.

Use Puppeteer’s PDF header or footer template

Puppeteer supplies the current page number and total page count through special classes in the HTML template passed to page.pdf(). They are not Tailwind utility classes or values you need to calculate in your application. Enable headers and footers, then put those classes on elements in a headerTemplate or footerTemplate.

await page.pdf({
  path: 'output.pdf',
  displayHeaderFooter: true,
  headerTemplate: '<div></div>',
  footerTemplate: `
    <div style="width:100%; text-align:center; font-size:10px;">
      Page <span class="pageNumber"></span> of <span class="totalPages"></span>
    </div>
  `,
  margin: { bottom: '0.5in', top: '0.5in' },
});

This is an illustrative configuration, not a reproduction tested against your application. Adjust the template and margins for your paper size, content, and intended header or footer height. Puppeteer documents the template classes and margin option; without specified margins, the documented default is no margins.

Apply the fix in a reliable order

  1. Check the options in the call that creates the PDF. Confirm displayHeaderFooter: true is present in the page.pdf() call used for the affected file. A setting in a different code path will not configure this call. Puppeteer’s documented default is false.
  2. Use the exact template classes. Put class="pageNumber" where the current page number should appear and class="totalPages" where the document’s total page count should appear. Class spelling and capitalization matter. These names are Puppeteer’s built-in hooks; do not substitute Tailwind classes or application data attributes.
  3. Keep the template’s styling explicit. Supply HTML in the PDF options and use inline CSS for the template’s layout, typography, and alignment. The API describes these as template strings; it does not promise that your page’s compiled Tailwind stylesheet or utility classes are available inside the template. Treat that separation as a practical caution, not a guarantee about every setup: verify the result with the Puppeteer and browser versions you actually use.
  4. Reserve space for the template. Give the top margin room for a header, the bottom margin room for a footer, or both if needed. The right amount depends on the paper size and template height. A template can be enabled and contain the correct classes yet still be clipped or crowded if the page has no space reserved for it.
  5. Inspect the result, not just the screen. Generate a multi-page PDF with the same browser and Puppeteer versions used in production. Check an early page, a middle page, and the last page to confirm that both values appear and that the final total is plausible for the output.

Why Tailwind styles may not reach the numbers

The PDF header and footer are supplied as their own HTML template strings. The Puppeteer API documentation establishes the template interface and injected page-number classes, but it does not promise that the main document’s Tailwind output is loaded into those templates. As a result, a class such as text-center may not produce the intended alignment there even if it works in the page body.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Adobe Acrobat Pro | PDF Software | Convert, Edit, E-Sign, Protect | PC/Mac Online Code | Activation Required
  • Create and edit PDFs. Collaborate with ease. E-sign documents and collect signatures. Get everything done in one app, wherever you go.
  • Edit text and images without jumping to another app.
  • E-sign documents or request e-signatures on any device. Recipients don’t need to log in to e-sign.
  • Convert PDFs to editable Microsoft Word, Excel, or PowerPoint documents.
  • Share PDFs for collaboration. Commenting features make it easy for reviewers to comment, mark up, and annotate.

For predictable template styling, put the needed styles directly on the template elements, as in the example’s style attribute. If your particular setup does make a stylesheet available to the template, you can test that arrangement, but do not assume it from the fact that the same classes work on the page itself. Keep the special pageNumber and totalPages classes even when you add your own styling; those are the hooks for the values.

Account for print media and print CSS

Page.pdf() generates the PDF using print CSS media. Rules in @media print, as well as other print-specific rules, can hide, reposition, or visually suppress page content. If body content changes between the browser view and PDF, inspect those rules as part of the diagnosis. Puppeteer documents that you can request screen media instead by calling page.emulateMediaType('screen') before page.pdf(). That changes the media type used for rendering; it does not replace the header/footer settings or their special classes.

Rank #2
Acrobat Pro | 1-Month Subscription | PDF Software |Convert, Edit, E-Sign, Protect |Activation Required [PC/Mac Online Code]
  • Create and edit PDFs. Collaborate with ease. E-sign documents and collect signatures. Get everything done in one app, wherever you go.
  • Edit text and images without jumping to another app.
  • E-sign documents or request e-signatures on any device. Recipients don’t need to log in to e-sign.
  • Convert PDFs to editable Microsoft Word, Excel, or PowerPoint documents.
  • Share PDFs for collaboration. Commenting features make it easy for reviewers to comment, mark up, and annotate.

If the numbers are present but their colors look different in the PDF, separate that issue from missing page values. Puppeteer notes that PDF colors are modified for printing by default. Its documented option for requesting exact colors is the CSS property -webkit-print-color-adjust. Color adjustment will not make a missing template or missing number appear.

Choose where page numbering belongs

Approach Use it when Key consideration
Puppeteer header or footer template You need Puppeteer’s current-page and total-page values, such as “Page X of Y.” Enable displayHeaderFooter; style the template explicitly and reserve margin space.
Numbering in the document’s print layout Your existing print CSS needs to control where page-number elements are rendered. This is a general implementation alternative, not a behavior established by the Puppeteer template documentation. Verify how your layout produces numbering and totals in your target browser.

For automatically injected current and total page values, the template approach is the one directly documented by Puppeteer. A document-layout approach may fit a project whose numbering is already managed by its print layout, but do not assume it provides the same built-in values or behaves identically across browser versions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
PDF Extra Lifetime - Professional PDF Editor - Best Adobe Acrobat Pro Alternative - Lifetime License for Windows PC
  • Perfect Adobe Acrobat Pro alternative – lifetime license for Windows 10 and 11.
  • EDIT text, images, pages, hyperlinks, designs in PDF documents. ORGANIZE PDFs.
  • READ and Comment on PDFs – Intuitive reading modes & document commenting and mark up tools!
  • CREATE, COMBINE, SCAN and COMPRESS PDFs.
  • FILL forms & Digitally Sign PDFs. Work with Digital certificates

Check fonts and rendering before changing code repeatedly

Puppeteer’s PDF guide says Page.pdf() waits for fonts by default. Even so, validate the generated file using the same browser and Puppeteer versions as production: the actual PDF is the useful test of whether your template, margins, print rules, and font rendering work together. Check several pages rather than relying on a single-page sample, since the total-page value is only meaningful in a multi-page output.

The consulted official Puppeteer documentation identified version 25.12.0 as of September 29, 2026. Its documented API behavior is a starting point, not proof of the cause in an individual project. If the code follows the documented pattern and the output remains wrong, compare the PDF options, Tailwind build, print stylesheet, and browser/Puppeteer versions in the environment that creates the file.

Rank #4
PDF Extra 2024| Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Lifetime License | 1 Windows PC | 1 User [PC Online code]
  • EDIT text, images & designs in PDF documents. ORGANIZE PDFs. Convert PDFs to Word, Excel & ePub.
  • READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.
  • CREATE, COMBINE, SCAN and COMPRESS PDFs
  • FILL forms & Digitally Sign PDFs. PROTECT and Encrypt PDFs
  • LIFETIME License for 1 Windows PC or Laptop. 5GB MobiDrive Cloud Storage Included.

Troubleshoot the common symptoms

Symptom Check Fix or next step
Neither header nor footer is visible Whether the actual PDF call has displayHeaderFooter: true. Enable it in that call. A template does not override the documented false default.
The header/footer appears, but the number values are absent Whether the template uses the exact pageNumber and totalPages classes. Add those classes to the elements where the values should appear.
Numbers exist but Tailwind formatting does not Whether the standalone template can access the stylesheet that supplies the utility classes. Use inline CSS for the template’s required styles, then verify the PDF in your specific setup.
Template content is clipped or overlaps the page Whether the relevant top or bottom margin leaves enough room for the template. Set margins appropriate to the page size and template height, then inspect the rendered output.
Body content differs from the browser view @media print and other print rules; Page.pdf() uses print media. Adjust the print rules, or use page.emulateMediaType('screen') before generating the PDF if screen media is intended.
Colors look altered, but text is visible Puppeteer’s print color adjustment behavior. Use -webkit-print-color-adjust when exact colors are required; this is a color issue, not a numbering fix.
The result differs between development and production The options, compiled Tailwind CSS, print styles, and browser/Puppeteer versions in each environment. Generate and inspect the PDF using production’s actual configuration before treating the behavior as resolved.

Performance, reliability, and cost considerations

This fix is an adjustment to the options passed to page.pdf(); the cited documentation provides no topic-specific benchmark or performance figure for header/footer templates. Avoid treating a particular generation time or throughput as guaranteed. For reliability, keep the PDF options and template together in the code path that creates the output, and inspect a multi-page production-version PDF after changes to templates, print CSS, or rendering versions. The supplied documentation does not establish a separate cost for adding page numbers.

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

Or skip the browser setup

If what you need is to capture a URL as a PDF rather than change the header/footer in this Puppeteer job, ScreenshotNeo is a website screenshot API and MCP server. It does not replace the Page.pdf() fix above when you need to control this Puppeteer template; it is an alternative capture workflow. Its API accepts one GET request, and its PDF options include paper size, margins, landscape orientation, and page ranges. See the ScreenshotNeo API documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
PDF Director 3 PLUS - Edit, Convert, Redact, Protect PDFs, Fill Forms for Win 11, 10, 8.1, 7
  • Full-featured PDF Editor: Edit text in the document
  • Fully convert PDF to Word and Excel and continue editing
  • NEW: Further development of existing functions
  • NEW: Even faster and more user-friendly
  • NEW: Over 75 small improvements in all areas
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo removes cookie or consent banners, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up for the free plan.

Frequently asked questions

Does this fix depend on a particular Tailwind version?

The documented number injection comes from Puppeteer’s template classes, not from Tailwind. The relevant setup question is whether your template can access the stylesheet containing the utility classes you want to use.

Where can I confirm the documented behavior?

Consult the official Puppeteer PDF options and PDF guide for the version used by your project; the findings above reflect the official documentation identified as version 25.12.0 on September 29, 2026.

Frequently Asked Questions

Does this fix depend on a particular Tailwind version?

The documented number injection comes from Puppeteer’s template classes, not from Tailwind. The relevant setup question is whether your template can access the stylesheet containing the utility classes you want to use.

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

Where can I confirm the documented behavior?

Consult the official Puppeteer PDF options and PDF guide for the version used by your project; the findings above reflect the official documentation identified as version 25.12.0 on September 29, 2026.

Quick Recap

Bestseller No. 1
Adobe Acrobat Pro | PDF Software | Convert, Edit, E-Sign, Protect | PC/Mac Online Code | Activation Required
Adobe Acrobat Pro | PDF Software | Convert, Edit, E-Sign, Protect | PC/Mac Online Code | Activation Required
Edit text and images without jumping to another app.; Convert PDFs to editable Microsoft Word, Excel, or PowerPoint documents.
$239.88
Bestseller No. 2
Acrobat Pro | 1-Month Subscription | PDF Software |Convert, Edit, E-Sign, Protect |Activation Required [PC/Mac Online Code]
Acrobat Pro | 1-Month Subscription | PDF Software |Convert, Edit, E-Sign, Protect |Activation Required [PC/Mac Online Code]
Edit text and images without jumping to another app.; Convert PDFs to editable Microsoft Word, Excel, or PowerPoint documents.
$29.99
Bestseller No. 3
PDF Extra Lifetime - Professional PDF Editor - Best Adobe Acrobat Pro Alternative - Lifetime License for Windows PC
PDF Extra Lifetime - Professional PDF Editor - Best Adobe Acrobat Pro Alternative - Lifetime License for Windows PC
Perfect Adobe Acrobat Pro alternative – lifetime license for Windows 10 and 11.; EDIT text, images, pages, hyperlinks, designs in PDF documents. ORGANIZE PDFs.
$99.99
Bestseller No. 4
PDF Extra 2024| Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Lifetime License | 1 Windows PC | 1 User [PC Online code]
PDF Extra 2024| Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Lifetime License | 1 Windows PC | 1 User [PC Online code]
READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.; CREATE, COMBINE, SCAN and COMPRESS PDFs
$99.99
Bestseller No. 5
PDF Director 3 PLUS - Edit, Convert, Redact, Protect PDFs, Fill Forms for Win 11, 10, 8.1, 7
PDF Director 3 PLUS - Edit, Convert, Redact, Protect PDFs, Fill Forms for Win 11, 10, 8.1, 7
Full-featured PDF Editor: Edit text in the document; Fully convert PDF to Word and Excel and continue editing
$29.99

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.