Search and Replace Text in PDF – Step-by-step Guide

  1. Sample PDF Invoice
  2. Set up Action Event
  3. Configure Custom API Call
  4. Test Zap
  5. Zap Test Result
  6. Search and Replace Text Output

Step 1: Sample PDF Invoice

In this tutorial we will show you how to search and replace specific text in a PDF file using PDF.co and Zapier. We will use this sample PDF Invoice and replace the highlighted Company Name and Client Name with different text.

 

Sample PDF File To Search And Replace Text
Sample PDF File To Search And Replace Text

 

Step 2: Set up Action Event

First, let’s choose PDF.co as the App and the Custom API Call as the Action Event. The Custom API Call allows us to use API endpoints that are not available in the Action Event dropdown box.

 

Use Custom API Call To Access All PDF.co API Endpoints

 

Step 3: Configure Custom API Call

Next, let’s configure the Custom API Call so we can use the Search and Replace API endpoint.

  • In the PDF.co API Endpoint field, select the v1/pdf/edit/replace-text endpoint.
  • In the Input JSON field, enter the JSON code that contains the URL, searchStrings[], and replaceStrings[] parameters.

Configure The Custom API Call With Search And Replace Endpoint
To follow along, you can use this sample JSON code.

{
  "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-to-text/sample.pdf",
  "searchStrings": [
    "Your Company Name",
    "Client Name"
  ],
  "replaceStrings": [
    "XYZ LLC",
    "ABCD"
  ],
  "caseSensitive": true,
  "pages": "",
  "password":"",
  "name": "finalFile" 
}

Step 4: Test Zap

Then, let’s send our Custom API Call configuration to PDF.co to make sure that we set it up correctly.

 

Send Custom API Call To PDF.co

 

Step 5: Zap Test Result

Great! Our PDF.co Zap test was successful. PDF.co generated a URL that we can use to view and download the PDF file. This URL is temporary and is set to expire after an hour by default.

PDF.co Test Successful

Step 6: Search and Replace Text Output

This is now the sample PDF Invoice with a new Company Name and Client Name.

 

PDF.co Search And Replace Text Output
PDF.co Search And Replace Text PDF Output

 

In this tutorial, you learned how to search and replace multiple texts in a PDF document using PDF.co and Zapier. You also became acquainted with the PDF.co Custom API Call where you can access all the PDF.co API endpoints.

Related Samples: