Add Text, Link, and Image to PDF – Step-by-step Guide

  1. Add Source File
  2. Install the Request Module
  3. Add API Key
  4. Source File, Result, Annotation, and Image
  5. Run Your Code
  6. PDF.co Web API Demo

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/PDF With Added Text And Link
Sample PDF/PDF With Added Text And Link

Step 1: Add Source File

First, copy or download the Python sample code here.

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 PDF.co API Key. You can get the API Key in your PDF.co dashboard.

PDF.co API Key

Step 4: Source File, Result, and Annotation

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

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

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

  • In lines 35 and 36, add the image’s x and y coordinates.
  • In lines 37 and 38, you can specify the image’s width and height.
  • In line 39, 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

Step 6: PDF.co Web API Demo

Here’s the PDF.co Web API in action.

Add Text and Images Web API with Links in Python
PDF.co Web API Demo

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

Related Pages:

Related Samples: