Skip to main content

Add HTML Header Footer to PDF

EditAdd HTML Header Footer to PDF

The Add HTML Header Footer to PDF API adds HTML content as headers, footers, or both to your PDF. You send the PDF (docContent, docName), htmlContent (plain HTML, not Base64), location (Header, Footer, or Both), optional pages, skipFirstPage, and margins. The API returns the PDF with the HTML applied. Use HTML and CSS for styling. Use the tester below to try it; more details are in the sections that follow.

Quick reference

Endpoint: POST /api/v2/AddHtmlHeaderFooter · Required: api-key, docContent, docName, htmlContent, location

Try it live

Use the form below to send your API key, PDF (Base64), HTML content, and location (Header, Footer, or Both). The response is the PDF with the header/footer applied. No code required—fill the fields and click Send request.

Loading API Tester...

Overview, parameters, and use cases

This endpoint adds HTML content as a header, footer, or both to your PDF. You provide plain HTML (and CSS) in htmlContent, choose location (Header, Footer, or Both), and optionally target specific pages or skip the first page. Margins (left, right, top, bottom in pixels) control spacing. The API returns the PDF with the HTML rendered in the chosen area.

Key features

  • HTML and CSS – Use plain HTML for content; style with inline CSS or style tags.
  • LocationHeader, Footer, or Both.
  • Page targetingpages: empty for all pages, or e.g. 1, 1,3,5, 2-5, 1,3,7-10, 2-.
  • MarginsmarginLeft, marginRight, marginTop, marginBottom in pixels.
  • skipFirstPage – Omit header/footer on the first page (e.g. for cover pages).
Best for

Use for branded headers/footers (logo, title, page info) or legal text. Combine with Add Page Number to PDF if you need page numbers in addition to custom HTML.

Prerequisites

Before using this endpoint, make sure you have:

  • A valid PDF4me API key (Get your API Key)
  • A PDF document in Base64 format or a public URL to a PDF file
  • HTML content for the header or footer

Response Format

The API returns a PDF document with HTML header/footer applied to the specified pages.

Get Help