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.
<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
- 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.
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
- 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.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →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
- 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.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
heightor 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:firstmargin 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.
Recommended Free Tools
cURL example (see the ScreenshotNeo API documentation):
Quick Recap
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.




