Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk4 min

How to Add Headers and Footers to wkhtmltopdf Output

Use wkhtmltopdf’s header/footer text settings for simple repeating labels or an HTML document for more control. Adjust margins and spacing to keep them in the PDF page area.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use wkhtmltopdf’s positional header and footer settings for short text, or point it to an HTML document when you need more layout control. Set page margins separately from header/footer spacing so the content and repeating elements have room to render.

Choose text settings or an HTML document

wkhtmltopdf supports left, center, and right text in both headers and footers. The settings also include font controls, a rule line, and spacing. For a more designed banner or other custom layout, you can supply a separate HTML document URL instead. These approaches offer different levels of layout control and markup complexity; the project does not identify one as universally preferable.

The project describes wkhtmltopdf as an open-source command-line tool that renders HTML to PDF using Qt WebKit. Project overview.

As an Amazon Associate I earn from qualifying purchases.

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

Add a simple repeating header or footer

The settings reference defines the relevant names as header.left, header.center, and header.right; footer settings use the corresponding footer.* names. Header and footer settings can be associated with an individual page object. Consult the help or manual for the wkhtmltopdf version installed on your machine for exact command-line syntax and supported values.

Start by checking your build’s available options:

wkhtmltopdf --help

Use the matching header settings to put short content at the left, center, or right of the top of each page. For a bottom element, use the footer equivalents. The project’s settings reference documents the families of options, but the sources available here do not establish a complete, verified command invocation for every build. Do not assume a command copied from a different version will work unchanged.

Settings to look for

  • header.left, header.center, and header.right place text across the header.
  • Header font name, font size, line, and spacing settings adjust its appearance and separation from page content.
  • Use the corresponding footer.* settings for the bottom of the page.
  • header.htmlUrl points to an HTML document for a custom header; the settings reference says the same settings apply to footers.

See the project’s settings reference and HeaderFooter API reference.

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.
Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Use HTML for a more controlled design

When positional text fields are too limited, create a separate HTML document for the header or footer and use the corresponding HTML URL setting. This lets you maintain markup for a more composed layout. The cited project documentation establishes the HTML-document option, but does not prescribe a particular markup pattern or guarantee identical rendering for every build; check the resulting PDF with your installed version.

Set margins and spacing to prevent collisions

Page margins and header/footer spacing are separate controls. The global page settings include margin.top and margin.bottom, while header/footer spacing controls the gap for those elements. The project cautions that excessive header spacing can place the header outside the PDF page and notes that increasing the top margin can correct that case.

If a header is missing or overlaps the body, reduce its spacing or increase the top margin, then inspect the PDF. Apply the analogous clearance check to a footer using the bottom margin and footer spacing, but verify the output rather than assuming every build behaves identically.

Add page numbers carefully

The global pageOffset setting adds a number to page numbers used in headers, footers, and the table of contents. The settings reference points to the manual for substitution sequences, but does not expose the complete token list here. Check wkhtmltopdf --help or the manual for your installed version before using page-number placeholders; token support and exact syntax should not be guessed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Troubleshoot common problems

  • Header or footer is absent: Confirm that the option is supported by your installed build, that you used the correct header or footer setting family, and that an HTML URL is reachable if you selected the HTML-document approach.
  • Header is clipped or outside the page: The project specifically warns that excessive header spacing can push it off-page. Adjust spacing and, if needed, increase margin.top; regenerate and inspect the PDF.
  • Body text overlaps a header or footer: Increase the corresponding page margin or reduce the header/footer spacing, then check the output pages for collisions.
  • Page number does not render as expected: Verify the placeholder sequence against the manual for the installed version, and check whether pageOffset is changing the displayed numbering.
  • Options differ across machines: Compare the installed versions and use each version’s own help or manual rather than relying on an unverified invocation.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Version and security considerations

The wkhtmltopdf downloads page lists 0.12.6 as the stable series and gives June 11, 2020 as its release date. That is the project page’s stated release information, not evidence that every system has that version or that it is compatible with every current platform. Check the version and platform details relevant to your installation on the official downloads page.

The same project page warns: “Do not use wkhtmltopdf with any untrusted HTML – be sure to sanitize any user-supplied HTML/JS, otherwise it can lead to complete takeover of the server it is running on!” Treat HTML input and custom header/footer documents as security-sensitive when they contain user-supplied content.

Or skip the browser setup

If your goal is to capture a website rather than generate a PDF with wkhtmltopdf, ScreenshotNeo offers a screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF; the API also supports page capture options such as PDF paper size, margins, and page ranges.

For example, this cURL request captures a URL as WebP:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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 API documentation for setup and options. Cookie and consent banners are accepted or removed before capture, along with known newsletter popups and chat widgets; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses indicate the page verdict and billing status. Its MCP server gives AI agents screenshot tools. The free plan includes 1,000 shots a month without a card; paid plans start at $5 for 3,000 shots.

Sign up for 1,000 free screenshots a month, with no card required.

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 *

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.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
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.