Insert Page Numbers into PDF

Purpose

This API enables you to insert page numbers into a PDF file, including options to customize font, style, numbering pattern, and placement in headers or footers.

HTTP Request URL

https://{zohoapis_domain}/pdfeditor/api/v1/pdf/insertpagenumber

Body Parameters

ParameterData TypeDescription
Mandatory Parameters

file


 

File

or

String


 

Upload the PDF file in which the page number needs to be inserted using one of the following methods:

  • Upload the PDF directly from your local drive or desktop.
  • If the PDF is available via a publicly accessible web URL, you can provide the URL using the same parameter.

Note: The maximum file size allowed for the input PDF is 50 MB. It cannot be more than 150 pages.

input_options

{

  "page_number_settings": {

    "sections": [

      {

        "range": "1-10",

        "format": {

          "font": {

            "name": "Helvetica",

            "size": 10,

            "style": "Bold"

          }

        },

        "numbering_config": {

          "type": "1",

          "start": 1

        },

        "date_config": {

          "format": "DD-MM-YYYY",

          "locale": "en-US",

          "timezone": "UTC"

        },

        "header": {

          "left": {

            "text": "Page <<page_number>> of <<total_pages>>",

            "offsets": {

              "top": 20,

              "left": 40

            }

          }

        },

        "footer": {

          "center": {

            "text": "Page <<page_number>> of <<total_pages>>",

            "offsets": {

              "bottom": 20

            }

          }

        }

      }

    ]

  }

}

 

page_number_setting - Contains the page number configuration as a JSON Object.

sections - List of configuration blocks, each defining how page numbers should be inserted for a specific page range.

range (optional) - Specify the page range from where the page number needs to be inserted. Defaults to all pages if not provided.

format(optional) - Defines the formatting for the page numbers. Defaults to Roboto and size 12 if not provided.

font(optional) - Contains font styling details.

name(optional) - Specify font name.

size (optional) - Specify font size.

style(optional) - Specify the font style.

numbering_config(optional) - Defines the numbering style and starting number for the page numbers. Defaults to 1,2,3 if not provided.

type (optional) - Specify the numbering type.

Examples:
• 1 → 1,2,3
• a → a,b,c
• A → A,B,C
• i → i,ii,iii
• I → I,II,III

start (optional) - Specify the starting number for page numbering.

date_config (optional) - Configuration for inserting the date. Defaults to 'dd-MM-yyyy' if not provided.

format (optional) - Format of the date.

locale - Specify the locale value. Defaults to 'en-US' if not provided.

Note: Mandatory if 'date_config' is used.

timezone - Timezone for rendering the date. Defaults to 'UTC' if not provided.

Note: Mandatory if 'date_config' is used.

header/footer (atleast one is mandatory) - Contains layout sections where page numbers or text can be added in header/footer.

left/center/right (atleast one mandatory in either header or footer) - Specify the placement and content of text in the left, center, or right position.

text (mandatory) - Specify the text content to be displayed. You may use placeholders like <<page_number>> and <<total_pages>>.

offsets (optional) - Specify the positioning offsets for the text, with top, bottom, left, and right values in pixels. Defaults to header/footer position if not provided.


 

output_settings

"name": "<new document name>"

}

Specify the name for the modified PDF document.

Note: To use this API, an OAuth token should be generated with the following scopes: ZohoWriter.pdfEditor.ALL

input_options

ParameterData TypePossible ValuesDefault Value
namestringWeb-safe fontsRoboto
sizeintegerMaximum upto 10812
stylestringNormal, Bold, Italic, Bold ItalicNormal
typestring1/a/A/i/I1

Sample Request

Copiedcurl --location --request POST "https://www.zohoapis.com/pdfeditor/api/v1/pdf/insertpagenumber" \
  --header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
  --form 'file=@"/Users/username/Documents/Sample.pdf"' \
  --form 'input_options="{\"page_number_settings\":{\"sections\":{\"header\":{\"left\":{\"text\":\"Page <<page_number>> of <<total_pages>>\"}}}}}"'  \
  --form 'output_settings=“{\”name\”:\”ModifiedFile.pdf\"}"'

Once the process begins, you will initially receive the 'status_url'. By invoking the 'status_url', you will be able to monitor the status of the scheduled job.

Sample Response

Copied{
    "status_check_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/insertpagenumber/job/f931a01183b33",
    "status": "inprogress"
}

Success Response

Copied{
	"download_url" :"https://pdf.zoho.com/pdfeditor/api/v1/pdf/insertpagenumber/download/f931a01183b33",
	"status": "success"
}