Add Text, Link, and Image to PDF using Web API in Python

In this demonstration, we will add text, a clickable link, and a company logo to PDF using the /v1/pdf/edit/add endpoint. Below are the images of the input and output PDFs.

Sample PDF
Sample PDF
PDF With Added Text And Link
PDF With Added Text And Link

Step 1: Add Source File

First, copy or download the Python sample code.

Step 2: Install the Request Module

Next, install the request module. Type the python -m pip install requests in your command line.

Step 3: Add API Key

Now, let’s open the Python sample code and add the API Key. You can get the API Key in your dashboard.

Add API Key

Step 4: Source File, Result, and Annotation

Let’s add our text details in the text annotation param.

  • In line 16, enter the source file URL. You can leave the default URL to follow along.
  • In line 25, add your desired output file name.
  • In lines 29 and 30, type in the text’s x and y coordinates. You can easily get these coordinates using the Simple PDF Viewer.
  • In line 31, enter the text you want to add to the PDF.
  • In lines 32 to 34, you can customize the font name, font size, and font color.

Now, let’s company logo in the image param.

  • In lines 38 and 39, add the image’s x and y coordinates.
  • In lines 40 and 41, you can specify the image’s width and height.
  • In line 42, enter the image’s URL or you can leave the default value.
Add Text and Images

Step 5: Run your Code

Now, let’s run the python program and click the file to view the output.

Run Your Code

In this tutorial, you learned how to add text, a clickable link, and a company logo to PDF in Python using the Web API. You also learned how to modify the source code to use it with your own files.

Video Guide