Add HTML Header Footer to PDF
Edit → Add 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.
Try the Add HTML Header Footer to PDF API
Endpoint: POST /api/v2/AddHtmlHeaderFooter · Required: api-key, docContent, docName, htmlContent, location
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.
Overview, parameters, and use cases
- Overview
- Parameters
- Use cases
What is Add HTML Header Footer to PDF?
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.
- Location – Header, Footer, or Both.
- Page targeting – pages: empty for all pages, or e.g.
1,1,3,5,2-5,1,3,7-10,2-. - Margins – marginLeft, marginRight, marginTop, marginBottom in pixels.
- skipFirstPage – Omit header/footer on the first page (e.g. for cover pages).
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.
API parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| api-key | string | Yes | Your PDF4me API key, Base64 encoded. Get it from the dashboard. |
| docContent | base64 | Yes | PDF file content (Base64). |
| docName | string | Yes | Output PDF file name (e.g. output.pdf). |
| htmlContent | string | Yes | HTML content (plain HTML, not Base64). |
| location | string | Yes | Header, Footer, or Both. |
| pages | string | No | Empty for all pages, or e.g. 1, 1,3,5, 2-5, 1,3,7-10, 2-. |
| skipFirstPage | boolean | No | Skip header/footer on first page. |
| marginLeft, marginRight, marginTop, marginBottom | number | No | Margins in pixels. |
| async | boolean | No | Enable asynchronous processing. |
When to use Add HTML Header Footer to PDF
- Branding – Add logo, company name, or title to every page (or selected pages).
- Legal and disclaimers – Put terms, confidentiality text, or version info in header or footer.
- Reports – Add document title, date, or section labels in HTML.
- Page layout – Use HTML/CSS for consistent headers and footers across long PDFs.
For request/response schemas and code samples, see Add Header Footer to PDF in the PDF4me API docs.
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.