PDF Search and Replace Text#
Available Methods#
/pdf/edit/replace-text#
Modify a PDF file by searching for specific text and replacing it with new text.
Method: POST
Endpoint: /v1/pdf/edit/replace-text
Attributes#
Note
Attributes are case-sensitive and should be inside JSON for POST request, for example:
{
"url": "https://example.com/file1.pdf"
}
Attribute |
Description |
Required |
---|---|---|
|
URL to the source file. 1 |
yes |
|
HTTP auth user name if required to access source |
no |
|
HTTP auth password if required to access source |
no |
|
The array of strings to search. |
yes |
|
The array of replacements strings. |
yes |
|
Limit the number of searches & replacements for every item. The default value is |
no |
|
Set to |
no |
|
Set to |
no |
|
File name for the generated output, the input must be in string format. |
no |
|
Set the expiration time for the output link in minutes (default is |
no |
|
Comma-separated indices of pages (or page ranges) that you want to use. The first-page index is always 0. For example, if you have a 7-page document that you want to be split into 3 separate PDFs but a different number of pages it would go like this: 0, 1, 2- or 1, 2, 3-7 which will result in 1 PDF with page one, 1 PDF with page two and one PDF with the rest of the pages. You can also use inverted page numbers adding |
no |
|
Password of PDF file, the input must be in string format. |
no |
|
Set |
no |
Query parameters#
No query parameters accepted.
Payload#
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-search-and-replace/sample-agreement-template-signature-page-1.pdf",
"searchStrings": [
"[CLIENT-NAME]",
"[CLIENT-COMPANY]"
],
"replaceStrings": [
"John Doe",
"Skynet 3000"
],
"caseSensitive": true,
"replacementLimit": 1,
"pages": "",
"password":"",
"name": "finalFile",
"async": false
}
Response 2#
{
"url": "https://pdf-temp-files.s3.amazonaws.com/e79f0b9c82984740973ca670d7c93cad/finalFile.pdf",
"pageCount": 1,
"error": false,
"status": 200,
"name": "finalFile.pdf",
"remainingCredits": 99089875,
"credits": 21
}
CURL#
{
"url": "https://pdf-temp-files.s3.amazonaws.com/e79f0b9c82984740973ca670d7c93cad/finalFile.pdf",
"pageCount": 1,
"error": false,
"status": 200,
"name": "finalFile.pdf",
"remainingCredits": 99089875,
"credits": 21
}
/pdf/edit/replace-text-with-image#
Modify a PDF file by searching for specific text and replacing it with an image.
Method: POST
Endpoint: /v1/pdf/edit/replace-text-with-image
Attributes#
Note
Attributes are case-sensitive and should be inside JSON for POST request, for example:
{
"url": "https://example.com/file1.pdf"
}
Attribute |
Description |
Required |
---|---|---|
|
URL to the source file. 1 |
yes |
|
HTTP auth user name if required to access source |
no |
|
HTTP auth password if required to access source |
no |
|
Single text replacement. Word or phrase to be replaced, the input must be in string format. |
yes |
|
Image URL or |
yes |
|
Limit the number of searches & replacements for every item. The default value is |
no |
|
Set to |
no |
|
Set to |
no |
|
File name for the generated output, the input must be in string format. |
no |
|
Set the expiration time for the output link in minutes (default is |
no |
|
Comma-separated indices of pages (or page ranges) that you want to use. The first-page index is always 0. For example, if you have a 7-page document that you want to be split into 3 separate PDFs but a different number of pages it would go like this: 0, 1, 2- or 1, 2, 3-7 which will result in 1 PDF with page one, 1 PDF with page two and one PDF with the rest of the pages. You can also use inverted page numbers adding |
no |
|
Password of PDF file, the input must be in string format. |
no |
|
Set |
no |
Query parameters#
No query parameters accepted.
Payload#
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-text/sample.pdf",
"searchString": "Your Company Name",
"caseSensitive": false,
"replaceImage": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-edit/logo.png",
"pages": "0",
"async": false
}
Response 2#
{
"url": "https://pdf-temp-files.s3.amazonaws.com/7ea2b532988742508906cff59be0180e/sample.pdf",
"pageCount": 1,
"error": false,
"status": 200,
"name": "sample.pdf",
"remainingCredits": 99150679,
"credits": 77
}
CURL#
curl --location --request POST 'https://api.pdf.co/v1/pdf/edit/replace-text-with-image' \
--header 'x-api-key: ' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-text/sample.pdf",
"searchString": "Your Company Name",
"caseSensitive": false,
"replaceImage": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-edit/logo.png",
"pages": "0",
"async": false
}'
Code samples#
Footnotes
- 1(1,2)
Supports links from Google Drive, Dropbox, and PDF.co Built-In Files Storage. To upload files via the API check out the File Upload section. Note: If you experience intermittent Too Many Requests or Access Denied errors, please try to add
cache:
to enable built-in URL caching. (e.gcache:https://example.com/file1.pdf
) For data security, you have the option to encrypt output files and decrypt input files. Learn more about user-controlled data encryption.- 2(1,2)
Response codes as follows:
Code
Description
200
The request has succeeded
400
Bad input parameters
401
Unauthorized
403
Not enough credits
405
Timeout error. To process large documents or files please use asynchronous mode (set the
async
parameter totrue
) and then check status using the /job/check endpoint. If a file contains many pages then specify a page range using thepages
parameter. The number of pages of the document can be obtained using the /pdf/info endpoint.