Add Page Numbers to a PDF Using PDF.co API Tester

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, you’ll learn how to use PDF.co’s API Tester to add page numbers to an existing PDF without writing an application.

Step 1: Open the API Tester

Open the PDF Add API Tester and select Try it.

Enter your PDF.co API key in the x-api-key authorization field. You can retrieve your key from your PDF.co account.

This demo uses the POST /v1/pdf/edit/add endpoint.

Step 2: Configure the Request

Set the request body to the following values. Replace the example url with a publicly accessible link to your PDF.

{
  "url": "https://example.com/document.pdf",
  "name": "numbered-document.pdf",
  "async": false,
  "annotations": [
    {
      "text": "{{$$PageNumber}}",
      "x": 290,
      "y": 20,
      "size": 12,
      "fontName": "Arial",
      "pages": "0-"
    }
  ]
}

The annotation settings control the numbering:

  • text: {{$$PageNumber}} inserts the current page number automatically.
  • x and y: Position the number on the page.
  • size and fontName: Set the text size and font.
  • pages: 0- applies the annotation to every page. Page selection uses zero-based indexing.

Use the PDF Inspector tool in your PDF.co account to identify suitable coordinates. Choose an empty area so the numbers do not overlap existing content.

Step 3: Send the Request

Send the request from the API Tester and inspect the response.

A successful response includes error: false and an output url. Open that link to view the numbered PDF.

Step 4: Download the Result

Check the number placement on several pages, then download the finished PDF. The output URL is temporary, so save a copy before it expires.

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

See Related Tutorials