Add Page Number to PDF
Edit → Add Page Number to PDF
The Add Page Number to PDF API adds page numbers to your PDF. You send the PDF (docContent, docName), pageNumberFormat (e.g. # of {1} where # is current page and {1} is total pages), alignX and alignY, optional margins, fontSize, isBold, isItalic, skipFirstPage, and async. The API returns the PDF with page numbers added. Use the tester below to try it; more details are in the sections that follow.
Try the Add Page Number to PDF API
Endpoint: POST /api/v2/AddPageNumber · Required: api-key, docContent, docName, pageNumberFormat, alignX, alignY
Use the form below to send your API key, PDF (Base64), format (e.g. "# of 1"), and position. The response is the PDF with page numbers. No code required—fill the fields and click Send request.
Overview, parameters, and use cases
- Overview
- Parameters
- Use cases
What is Add Page Number to PDF?
This endpoint adds page numbers to specified pages of a PDF. You choose the format with pageNumberFormat: use # for the current page and {1} for the total number of pages. Position is set by alignX (left, center, right) and alignY (top, middle, bottom), optional margins in mm, fontSize (8–72), isBold, isItalic, and skipFirstPage to omit numbering on the first page.
Page number format options
- # – Placeholder for the current page number.
- 1 – Placeholder for the total number of pages.
- Examples:
"# of {1}"→ "1 of 10", "2 of 10";"Page #"→ "Page 1", "Page 2";"# / {1}"→ "1 / 10";"- # -"→ "- 1 -";"[#/{1}]"→ "[1/10]";"(#)"→ "(1)";"#"→ just "1", "2", etc.
Key features
- Format – pageNumberFormat with
#and{1}as above. - Position – alignX (left, center, right), alignY (top, middle, bottom), marginXinMM, marginYinMM.
- Styling – fontSize (8–72), isBold, isItalic.
- skipFirstPage – Omit page number on the first page (e.g. for cover).
Use for reports, manuals, or any multi-page PDF that needs pagination. Combine with Add HTML Header Footer to PDF or Add Margin to PDF for consistent layout.
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). |
| pageNumberFormat | string | Yes | Format with # and {1} (e.g. "# of 1", "Page #"). |
| alignX | string | Yes | left, center, right. |
| alignY | string | Yes | top, middle, bottom. |
| marginXinMM, marginYinMM | integer | No | Margins from edge in mm (0–100). |
| fontSize | integer | No | 8–72. |
| isBold, isItalic | boolean | No | Bold or italic. |
| skipFirstPage | boolean | No | Skip numbering on first page. |
| async | boolean | No | Enable asynchronous processing. |
When to use Add Page Number to PDF
- Reports and manuals – Add "Page 1 of 10" or "1 / 10" style numbering.
- Legal and contracts – Number pages for reference (e.g. "Page #" or "(#)").
- Print-ready PDFs – Ensure every page has a visible page number before printing or distribution.
For request/response schemas and code samples, see Add Page Number 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
Response Format
The API returns a PDF document with page numbers added according to your specifications.