Find and Replace Text

Purpose

This API allows you to find specific text patterns and replace them throughout a PDF document.

Quick Reference

PropertyValue
MethodPOST
Request URL (Download)https://{zohoapis_domain}/pdfeditor/api/v1/pdf/content/replace
Request URL (Store)https://{zohoapis_domain}/pdfeditor/api/v1/pdf/content/replace/store
Request URL (Callback)https://{zohoapis_domain}/pdfeditor/api/v1/pdf/content/replace/callback

Body Parameters

ParameterValueMandatory/OptionalDescription
fileFile or StringMandatoryUpload the PDF file from your local drive or desktop. If the PDF file is available via a publicly accessible web URL, you can provide the URL using the same parameter.
input_options{
  "replacements": [ { ... } ],
  "case_sensitive": true,
  "whole_word": false,
  "include_bookmarks": false,
  "include_comments": false,
  "page_range": "all"
}
MandatorySpecify the find/replace pairs and search behavior.
passwordStringOptionalIf the input PDF is password protected, specify the password to unlock it.
output_settings{
  "name": "<document_name>",
  "folder_id": "<folder_id>",
  "overwrite_existing_file": true | false
}
Mandatory for store variantname – Specify the name for the modified PDF document.
folder_id – Specify the ID of the WorkDrive folder in which to store the output file.
overwrite_existing_file(optional) – Set to true to overwrite an existing file with the same name in the folder.
callback{
  "invoke_url": "<callback_url>",
  "timeout": 60,
  "retry_interval": 60,
  "headers": {
    "header_name": "header_value"
  },
  "http_method_type": "post"
}
Mandatory for callback variantSpecify the callback delivery configuration for the /callback variant.

input_options Parameters

ParameterData TypePossible ValuesDefault Value
replacementsJSON ArrayArray of find/replace objects. See replacements Parameters.
case_sensitiveBooleantrue, falsetrue
whole_wordBooleantrue, falsefalse
include_bookmarksBooleantrue, falsefalse
include_commentsBooleantrue, falsefalse
page_rangeStringall, 1-5, 1,3,5, odd, evenall

replacements Parameters

ParameterData TypePossible ValuesDefault Value
findStringText to search for
replaceStringReplacement text

callback Parameters

ParameterData TypePossible ValuesDefault Value
invoke_urlStringURL. Maximum length: 300 characters.
timeoutInteger10 to 120 seconds60 seconds
retry_intervalInteger60 to 28800 seconds60 seconds
headersJSON ObjectMaximum 10 keys. Allowed characters for keys: alphabets, numbers, hyphen, underscore, dot. Maximum key length: 100. Maximum value length: 2500.
http_method_typeStringput, postpost

Notes and Limits

  • The maximum file size allowed for the input PDF is 50 MB.
  • By default, the search operates on page body text only. Use include_bookmarks and include_comments to extend the search scope.
  • Form fields are not searched by this API.
  • The store variant requires a Zoho WorkDrive account.
  • To use the download or callback variants, an OAuth token should be generated with the following scopes: ZohoWriter.pdfEditor.ALL
  • To use the store variant, an OAuth token should be generated with the following scopes: ZohoWriter.pdfEditor.ALL, WorkDrive.files.ALL, WorkDrive.organization.ALL

Possible Errors

Refer to the following pages for the list of possible errors for this API:

Download Variant Sample Request

Copiedcurl --location --request POST "https://{zohoapis_domain}/pdfeditor/api/v1/pdf/content/replace" \
  --header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
  --form 'file=@/Users/username/Documents/Original.pdf' \
  --form 'password="pdf_password"' \
  --form 'input_options={"replacements": [{"find": "confidential", "replace": "public"}, {"find": "draft", "replace": "final"}], "case_sensitive": true, "whole_word": false, "include_bookmarks": true, "include_comments": true, "page_range": "1-10"}'

Store Variant Sample Request

Copiedcurl --location --request POST "https://{zohoapis_domain}/pdfeditor/api/v1/pdf/content/replace/store" \
  --header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
  --form 'file=@/Users/username/Documents/Original.pdf' \
  --form 'password="pdf_password"' \
  --form 'input_options={"replacements": [{"find": "confidential", "replace": "public"}], "case_sensitive": true, "whole_word": false, "include_bookmarks": true, "include_comments": true, "page_range": "1-10"}' \
  --form 'output_settings={"name": "Replaced_Text.pdf", "folder_id": "<folder_id>", "overwrite_existing_file": true}'

Callback Variant Sample Request

Copiedcurl --location --request POST "https://{zohoapis_domain}/pdfeditor/api/v1/pdf/content/replace/callback" \
  --header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
  --form 'file=@/Users/username/Documents/Original.pdf' \
  --form 'password="pdf_password"' \
  --form 'input_options={"replacements": [{"find": "confidential", "replace": "public"}], "case_sensitive": true, "whole_word": false, "include_bookmarks": true, "include_comments": true, "page_range": "1-10"}' \
  --form 'callback={"invoke_url": "https://www.example.com/v1/api/callback/savecallback", "timeout": 120, "retry_interval": 60, "http_method_type": "post"}'

Download Variant Sample Response

Copied{
  "status": "inprogress",
  "status_check_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/content/replace/job/e9051e30fd7f0093cba4247d1f831e03e945a127bde429ed6e9ef3a703b15a6060b830256c650cb88a3f687773c33076"
}

Download Variant Success Response

Copied{
  "status": "success",
  "download_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/content/replace/download/b7f3e5c9a1d4e8f2b6a9c3e7f1d5a9b3",
  "response_generated_time": 1780912499331
}

Store Variant Sample Response

Copied{
  "status": "inprogress",
  "status_check_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/content/replace/job/2ae74c719bdb14ed9941fe351ade742439bf75ab0fb8fdf0a68b57a7a60cbd54ab7cb7bea5d0fafb4d2560a90331aaf8",
  "document_id": "hf3e60435a4c7576f4d21a16cfc292a4c64a9",
  "document_url": "https://workdrive.zoho.com/file/hf3e60435a4c7576f4d21a16cfc292a4c64a9"
}

Store Variant Success Response

Copied{
  "status": "success",
  "document_id": "hf3e60435a4c7576f4d21a16cfc292a4c64a9",
  "document_url": "https://workdrive.zoho.com/file/hf3e60435a4c7576f4d21a16cfc292a4c64a9",
  "response_generated_time": 1780912529135
}

Callback Variant Sample Response

Copied{
  "status": "inprogress",
  "status_check_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/content/replace/job/1d358192770dc68d173ca34b8f7c9dcb121ad0bf3d6307b7387be79e76dacf586f9d62cd253c26020f8c3dcf79d51b6b"
}

Callback Variant Success Response

Copied{
  "status": "success",
  "callback_response": {
    "invoked_time": 1780912655806,
    "http_status_code": 200,
    "message": {
      "download_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/content/replace/download/b7f3e5c9a1d4e8f2b6a9c3e7f1d5a9b3",
      "response_generated_time": 1780912656237
    }
  }
}