Skip to main content

POST /v1/pdf/edit/delete-text

When using regular expressions in JSON payloads, ensure that backslashes are properly escaped. For example, a single backslash \ should be written as \\.

Attributes

Attributes are case-sensitive and should be inside JSON for POST request. for example: { "url": "https://example.com/file1.pdf" }
AttributeTypeRequiredDefaultDescription
urlstringYes-URL to the source file url attribute
callbackstringNo-The callback URL (or Webhook) used to receive the POST data. see Webhooks & Callbacks. This is only applicable when async is set to true.
httpusernamestringNo-HTTP auth user name if required to access source URL.
httppasswordstringNo-HTTP auth password if required to access source URL.
searchStringsarray[string]Yes-The array of strings to search.
redactionsarrayNo-A list of redaction objects, each defining a rectangular area to remove or cover. Each redaction object includes the following fields:
    pageintegerYes-The zero-based index of the page where the redaction should be applied. For example, 0 = first page.
    xfloatYes-The X-coordinate of the top-left corner of the redaction box, in PDF units (points). Use PDF Edit Add Helper to measure coordinates.
    yfloatYes-The Y-coordinate of the top-left corner of the redaction box, in PDF units (points). Use PDF Edit Add Helper to measure coordinates.
    widthfloatYes-The width of the redaction area in points. Use PDF Edit Add Helper to measure coordinates.
    heightfloatYes-The height of the redaction area in points. Use PDF Edit Add Helper to measure coordinates.
replacementLimitintegerNo0Limit the number of searches & replacements for every item. The value 0 means every found occurrence will be replaced.
caseSensitivebooleanNotrueSet to false to don’t use case-sensitive search.
regexbooleanNofalseSet to true to use regular expression for search string(s).
MakeUnsearchablebooleanNofalseIf true, the output PDF is made unsearchable by replacing all pages with images. If false, the document remains searchable with only the specified text removed.
namestringNo-File name for the generated output, the input must be in string format.
expirationintegerNo60Set the expiration time for the output link in minutes. After this specified duration, any generated output file(s) will be automatically deleted from PDF.co Temporary Files Storage. The maximum duration for link expiration varies based on your current subscription plan. To store permanent input files (e.g. re-usable images, pdf templates, documents) consider using PDF.co Built-In Files Storage.
pagesstringNoall pagesSpecify page indices as comma-separated values or ranges to process (e.g. “0, 1, 2-” or “1, 2, 3-7”). The first-page index is 0. If not specified, the default configuration processes all pages.
passwordstringNo-Password for the PDF file.
asyncbooleanNofalseSet async to true for long processes to run in the background, API will then return a jobId which you can use with the Background Job Check endpoint. Also see Webhooks & Callbacks
profilesobjectNo-See Profiles for more information.
    outputDataFormatstringNo-If you require your output as base64 format, set this to base64
    removeTextUnderPatchbooleanNotrueControls whether to remove text under the patch or not
    usepatchbooleanNofalseControls whether to use a patch or not
    patchColorstringNo#000000Controls the color of the patch
    DataEncryptionAlgorithmstringNo-Controls the encryption algorithm used for data encryption. See User-Controlled Encryption for more information. The available algorithms are: AES128, AES192, AES256.
    DataEncryptionKeystringNo-Controls the encryption key used for data encryption. See User-Controlled Encryption for more information.
    DataEncryptionIVstringNo-Controls the encryption IV used for data encryption. See User-Controlled Encryption for more information.
    DataDecryptionAlgorithmstringNo-Controls the decryption algorithm used for data decryption. See User-Controlled Encryption for more information. The available algorithms are: AES128, AES192, AES256.
    DataDecryptionKeystringNo-Controls the decryption key used for data decryption. See User-Controlled Encryption for more information.
    DataDecryptionIVstringNo-Controls the decryption IV used for data decryption. See User-Controlled Encryption for more information.

Showing Redacted Text

By default when we delete text using post-tag-pdf-edit-delete-text it will simply remove text leaving a space where the text was. In the case where you need to blackout deleted text it can be acheived using following profiles parameters.
  • Set UsePatch parameter to true.
  • Set PatchColor parameter to color we want to use for redacting in hex format. For example: 'PatchColor': '#000000'.
In case we want to only blackout text, but not remove it so that we can still copy it, we can do so using RemoveTextUnderPatch parameter and set it to false.
If RemoveTextUnderPatch is set to false then a user could still copy the text making the redaction less secure than you might require!
{
 "profiles": "{'UsePatch': true, 'PatchColor': '#000000', 'RemoveTextUnderPatch': true}"
}

Query parameters

No query parameters accepted.

Responses

ParameterTypeDescription
urlstringDirect URL to the final PDF file stored in S3.
outputLinkValidTillstringTimestamp indicating when the output link will expire
pageCountintegerNumber of pages in the PDF document.
errorbooleanIndicates whether an error occurred (false means success)
statusstringStatus code of the request (200, 404, 500, etc.). For more information, see Response Codes.
namestringName of the output file
creditsintegerNumber of credits consumed by the request
remainingCreditsintegerNumber of credits remaining in the account
durationintegerTime taken for the operation in milliseconds

Example Payload

To see the request size limits, please refer to the Request Size Limits.
{
  "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-text/sample.pdf",
  "name": "pdfWithTextDeleted",
  "caseSensitive": "false",
  "searchString": "Invoice",
  "replacementLimit": 0,
  "async": false
}

Example Response

To see the main response codes, please refer to the Response Codes page.
{
  "url": "https://pdf-temp-files.s3.us-west-2.amazonaws.com/ZOSEQZFNVCYLD5N5CJFVIYQKBVLR8OKD/pdfWithTextDeleted.pdf?X-Amz-Expires=3600&X-Amz-Security-Token=FwoGZXIvYXdzECYaDKOO4WmO5C5shyOYYSKCAVsAo6VkB5HQjTBd9dMlJujQdEkPfNdPeLfq2mF54s2ESZBmIAJ5UgDUo3J9R475CCS4M3nuuo%2FSJwRy5gNiJdb1ZY0uCtP87x83nH%2B%2BSDu5JK%2F%2BEOrd3MREt8KE3BsQOrv%2FKMdnK%2BT5nJ2x2hC87vHue%2FudY7%2FWX54vx4tfFobEyhEozLbPnwYyKOdEsYYWH7e8tm7XV4UeKxCoKMaXSEPvOod80hR62qXnEI42fOsON3M%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIA4NRRSZPHLUVIAIPX/20230220/us-west-2/s3/aws4_request&X-Amz-Date=20230220T205521Z&X-Amz-SignedHeaders=host&X-Amz-Signature=9f79c1a30d4f373e495e735e908375dad2ae6dcafcee761a477748c2b8298605",
  "pageCount": 1,
  "error": false,
  "status": 200,
  "name": "pdfWithTextDeleted.pdf",
  "credits": 21,
  "duration": 189,
  "remainingCredits": 96235635
}
Inconsistent URL Encoding in cURL Output: When using cURL to make API requests, the output JSON may show URL characters encoded as Unicode escape sequences. For example, the ampersand character (&) may appear as \u0026 in the cURL output. This is normal JSON encoding behavior and does not affect the validity of the URL. The URL will function correctly when used, as JSON parsers automatically decode these escape sequences. If you’re parsing the response programmatically, your JSON parser will handle this conversion automatically.

Code Samples

  • CURL
  • JavaScript/Node.js
  • Python
  • C#
  • Java
  • PHP
curl --location --request POST 'https://api.pdf.co/v1/pdf/edit/delete-text' \
--header 'Content-Type: application/json' \
--header 'x-api-key: *******************' \
--data-raw '{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-text/sample.pdf",
"name": "pdfWithTextDeleted",
"caseSensitive": "false",
"searchString": "Invoice",
"replacementLimit": 0,
"async": false
}'