How to Add Page Numbers to a PDF File using PDF.co Web API
Sep 2, 2024·4 Minutes Read
PDF.co offers a variety of functionalities to help you with your PDF. These functionalities include PDF merging/splitting, search/replace text, PDF data extraction, PDF filler, document parsing, barcode reader, barcode generator, etc.
In this tutorial, we will show you how to add page numbers to a PDF file using PDF.co Web API.
IN THIS TUTORIAL
Step 1: Open PDF.co Account
- Let’s begin. First, let’s start by opening your PDF.co account and the Request Tester menu.

Step 2: Request Tester Page
- For Choose PDF.co API endpoint field, search and select
v1/pdf/edit/add
. This endpoint can add multiple pages in a single PDF. - For the Input Parameters field, override the URL param with a link or input with a file.

Step 3: Enter JSON Code
Let’s add the JSON Code and set up the parameters
- For the Async param, will set it to false.
- For Encrypt param, set it to true.
- For the Inline param, set it to true.
- In the Name param, type in your desired output file name.
Let’s set up the Annotations param
- In the Text param, enter the macros
{{$$PageNumber}}
to automatically add page numbers in the PDF file. - For X and Y params, add the coordinates where you want to add the page number. You can get the coordinates of your PDF file with our PDF/Edit/Add Helper.
- In the Size param, add the size of your page number.
- For the Pages param, enter
0-
so we can add numbers to all pages in a PDF file.

{
"async": false,
"encrypt": true,
"inline": true,
"name": "Output_File",
"annotations": [
{
"text": "{{$$PageNumber}} ",
"x": 290,
"y": 7,
"size": 20,
"pages": "0-"
}
]
}
After setting up the code, click on the Run Request button to send a request.
Step 4: Result
- Great! We successfully run the request, kindly click on the URL to view the output, or directly download the output file.

In this tutorial, you learned how to add page numbers to a PDF file using PDF.co Web API. You also learned how to use the v1/pdf/edit/add endpoint and add multiple page numbers in a single PDF.
Related Tutorials


Barcode Generation API - Webinar for Advanced Programmers
Sep 2, 2024·4 Minutes Read

How to Convert Outlook Email to PDF using PDF.co and Make
Sep 9, 2024·6 Minutes Read
