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 desk4 min

How to Add Page Numbers and Headers with PDFShift

Use PDFShift’s header object and {{ page }} and {{ total }} variables to add page numbers, then account for header height, embedded assets, and first-page margins.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To add repeating page numbers and a header to a PDFShift PDF, send a header object with your conversion request. Put HTML containing {{ page }} (and optionally {{ total }}) in header.source, then set header.height high enough for the design. PDFShift’s Node/Unfetch guide demonstrates this with a POST to its v3 PDF conversion endpoint and an X-API-Key header.

Configure the header and page numbers

PDFShift accepts a header object with source, height, and optional start_at. The source can be a URL or raw HTML. For page numbers, raw HTML is convenient because you can place the page variables exactly where they should appear.

As an Amazon Associate I earn from qualifying purchases.

The documented variables are {{ title }}, {{ url }}, {{ page }}, {{ total }}, and {{ date }}. Use {{ page }} for the current page and {{ total }} for the total page count. PDFShift documents the date format as M/D/YY-H:MM am/pm.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<div>Page {{ page }} of {{ total }}</div>

Set height to accommodate the actual header; PDFShift accepts pixels by default, as well as mm, cm, or in. The guide does not prescribe a universal height, so check the result against your font size, padding, and page layout. By default the header appears on page one. Set start_at when it should begin on a later page.

#1 Best Overall
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.

Send a PDFShift conversion request

This follows PDFShift’s documented Node/Unfetch example pattern: a POST request, JSON body, API key in X-API-Key, a URL as the source document, and raw HTML for the header. Replace YOUR_API_KEY and the source URL with your values.

const response = await fetch('https://api.pdfshift.io/v3/convert/pdf', {
  method: 'POST',
  headers: {
    'X-API-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    source: 'https://example.com/report',
    header: {
      source: '<div style="font-size: 10px; text-align: right;">Page {{ page }} of {{ total }}</div>',
      height: '20mm'
    }
  })
});

if (!response.ok) {
  throw new Error(`PDFShift request failed: ${response.status} ${await response.text()}`);
}

const pdf = Buffer.from(await response.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('report.pdf', pdf));

The endpoint and authentication pattern above are the ones shown in PDFShift’s official Node/Unfetch header and footer guide. Adapt request details if your HTTP client or application uses a different setup.

Choose header, footer, and page range behavior

Header on every page

Leave start_at out for the documented default: the header starts on page one. Place the number variables in the header source; PDFShift’s guide shows {{ page }} and {{ total }} together.

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

Header only from a later page

Set start_at to the first page where the header should appear. This is useful when the first page has a distinct cover layout. Remember that the header’s reserved space can still affect pagination; see the first-page overflow section below.

Rank #2
MobiPDF Lifetime - Professional PDF Editor for Windows | Edit, Sign & Convert PDFs | Best Adobe Acrobat Pro Alternative | Lifetime License
  • Edit PDFs with Ease. Modify text, images, and layouts directly within your PDF documents.
  • Convert & Organize. Export PDFs to Word, Excel, or ePub, and organize files with ease.
  • Read & Annotate. Enjoy intuitive reading modes and powerful tools to comment, highlight, and mark up PDFs.
  • Create & Manage PDFs. Create new PDFs, combine multiple files, scan documents, and compress for easy sharing.
  • Fill & Sign Forms. Complete forms and digitally sign documents with secure e-signature tools.

Footer instead of, or alongside, a header

Footer configuration follows the same pattern as a header: provide its source and height, and place page variables in the footer content. Use a footer when page numbering belongs at the bottom of the page. If both are present, account for the space and margins required by both.

Keep styles and assets available to the header

Header and footer content must be self-contained. PDFShift says external network requests for CSS, JavaScript, and fonts do not work in header/footer content. Put the necessary styling inline or embed the required resources rather than relying on a remote stylesheet or font URL.

Using a custom font

For a custom font, PDFShift’s Help Center instructs users to Base64-encode the font and include and use it in both the main document and the header or footer. PDFShift reports successful testing with TrueType and WOFF2 fonts. See PDFShift’s custom-font instructions.

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

Prevent a later-starting header from pushing page-one content

A header or footer reserves document margin. PDFShift explains that if a header starts on a later page while page one already fills its available height, the reserved space can push content onto page two. For a later-starting header, its Help Center suggests removing the top margin on the first page:

Rank #3
Scrivar PDF Pro - Organize, Edit, Compress, Convert, Merge, eSign, OCR & 30+ tools | Lifetime License
  • EVERY PDF TOOL UNLOCKED - 30+ tools in one app: edit text and images, convert, merge, split, compress, sign, OCR, redact, watermark, batch process, and more. No feature gates, no upsells, nothing held back.
  • PAY ONCE, OWN FOREVER — A one-time purchase, not a subscription. Other apps runs $240/year — Scrivar is yours for life, with free updates included.
  • UNLIMITED eSIGN, BUILT IN — Send contracts and forms for signature and track every step. Recipients sign in their browser with no account or app needed. Replace DocuSign and save hundreds a year.
  • PC, MAC, AND WEB — Install on any Win 10/11 PC or macOS 11+ Mac (Intel or Apple Silicon), or work in your browser at scrivar.com. Same tools, same account, everywhere you work.
  • OCR + FULL OFFICE CONVERSION — Turn scanned documents into searchable, selectable text, and convert PDFs to and from Word, Excel, and PowerPoint with formatting kept intact.
@page:first {
  margin-top: 0;
}

For a footer, the corresponding first-page rule is:

@page:first {
  margin-bottom: 0;
}

These are patterns to adjust to your existing page margins and layout, especially if the PDF uses both a header and footer. Check the page boundary after conversion rather than assuming a margin change is harmless. The explanation and workaround are in PDFShift’s first-page overflow article.

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

Troubleshoot common layout problems

  • The page number is missing or appears literally: Confirm the variables are in the header or footer source itself, and that the source is being passed as the intended HTML.
  • The header is clipped: Increase height or reduce the header’s text size, padding, or line height. Height is document-dependent; inspect the rendered PDF.
  • Remote styling or a font does not load: Header/footer content cannot rely on network-loaded CSS, JavaScript, or fonts. Make the styles self-contained and embed custom fonts as Base64 in both the document and header/footer.
  • Page one spills onto page two: If the header or footer starts after page one and the first page is already full, use the relevant @page:first margin pattern and adjust it for the document’s existing margins.
  • The header starts on the wrong page: Check start_at; omitting it uses the documented default of page one.

Or skip the browser setup

If the source document is a web page and you need an image capture rather than a PDFShift-generated PDF, ScreenshotNeo is a website screenshot API and MCP server. It provides a one-request capture and can return PNG, JPEG, WebP, or PDF. Its API does not reproduce PDFShift’s specific header-template workflow; use it when capturing a page as-is is the right outcome.

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

cURL example (see the ScreenshotNeo API documentation):

Quick Recap

Bestseller No. 1
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. 2
MobiPDF Lifetime - Professional PDF Editor for Windows | Edit, Sign & Convert PDFs | Best Adobe Acrobat Pro Alternative | Lifetime License
MobiPDF Lifetime - Professional PDF Editor for Windows | Edit, Sign & Convert PDFs | Best Adobe Acrobat Pro Alternative | Lifetime License
Edit PDFs with Ease. Modify text, images, and layouts directly within your PDF documents.; Convert & Organize. Export PDFs to Word, Excel, or ePub, and organize files with ease.
$99.99
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/report -o shot.webp

ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. AI agents can use its MCP server, and the free plan includes 1,000 screenshots each month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo’s free plan.

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 *

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.

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
Crashes, No Sound, or Screen Glitches?Free driver scan
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.