Search and Redact

Processor lets you create redactions using simple text search rules — any piece of text matching a provided query is covered by the redaction annotations. For example, to redact any occurrence of the word “pspdfkit,” you could use the following:

{
  "type": "createRedactions",
  "strategy": "text",
  "strategyOptions": {
    "text": "ACME Bank"
  }
}

Applying Redactions

After redaction annotations are created, they need to be applied to the document to effectively and permanently remove the covered content. You can achieve this by adding the applyRedactions operation to the operations pipeline.

ℹ️ Note: The applyRedactions operation is always executed as the last step in the operations pipeline, regardless of its actual position in the list of operations.

See the following sections for usage examples. Before you get started, make sure Processor is up and running.

Creating and Applying Redactions in a File on Disk

Send a request to the /process endpoint, attaching an input file and the operations JSON:

curl -X POST http://localhost:5000/process \
  -F file=@/path/to/example.pdf \
  -F operations='{
  "operations": [
    {
      "type": "createRedactions",
      "strategy": "text",
      "strategyOptions": {
        "text": "ACME Bank"
      }
    },
    {
      "type": "applyRedactions"
    }
  ]
}' \
  -o result.pdf 
POST /process HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary

--customboundary
Content-Disposition: form-data; name="file"; filename="example.pdf"
Content-Type: application/pdf

<PDF data>
--customboundary
Content-Disposition: form-data; name="operations"
Content-Type: application/json

{
  "operations": [
    {
      "type": "createRedactions",
      "strategy": "text",
      "strategyOptions": {
        "text": "ACME Bank"
      }
    },
    {
      "type": "applyRedactions"
    }
  ]
}
--customboundary--

This will create redaction annotations and apply them to the file, removing the content beneath them.

Creating and Applying Redactions in a File from a URL

Send a request to the /process endpoint and include a URL pointing to the file you want to redact:

curl -X POST http://localhost:5000/process \
  -F url=https://pspdfkit.com/downloads/examples/credit-card-application.pdf \
  -F operations='{
  "operations": [
    {
      "type": "createRedactions",
      "strategy": "text",
      "strategyOptions": {
        "text": "ACME Bank"
      }
    },
    {
      "type": "applyRedactions"
    }
  ]
}' \
  -o result.pdf 
POST /process HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary

--customboundary
Content-Disposition: form-data; name="url"

https://pspdfkit.com/downloads/examples/credit-card-application.pdf
--customboundary
Content-Disposition: form-data; name="operations"
Content-Type: application/json

{
  "operations": [
    {
      "type": "createRedactions",
      "strategy": "text",
      "strategyOptions": {
        "text": "ACME Bank"
      }
    },
    {
      "type": "applyRedactions"
    }
  ]
}
--customboundary--

This will create redaction annotations and apply them to the file, removing the content beneath them.