Extract Data from Bank Statements

Information

PSPDFKit Processor has been deprecated and replaced by PSPDFKit Document Engine. All PSPDFKit Processor licenses will work as before and be supported until 15 May 2024 (we will contact you about license migration). To start using Document Engine, refer to the migration guide. With Document Engine, you’ll have access to robust new capabilities (read the blog for more information).

This guide explains how to extract key-value pairs (KVPs) from bank statements using Processor. For example, this enables you to extract IBANs or account numbers. For more information, refer to the guide on how key-value pair extraction works.

Before you get started, make sure Processor is up and running.

You can download and use either of the following sample documents for the examples in this guide:

You’ll be sending multipart POST requests with instructions to Processor’s /build endpoint. To learn more about multipart requests, refer to our blog post on the topic, A Brief Tour of Multipart Requests.

Check out the API Reference to learn more about the /build endpoint and all the actions you can perform on PDFs with PSPDFKit Processor.

Sending the Request to Extract Data

To extract key-value pairs from a bank statement, post a multipart request to the /build API endpoint. In the instructions, specify the following output parameters:

  • type specifies the output type. Set this to json-content.

  • keyValuePairs is a Boolean value that determines whether to extract key-value pairs.

  • language specifies the language used for recognizing text with optical character recognition (OCR). Sometimes, text is stored in a PDF or an image in a way that makes it so you cannot search or copy it. PSPDFKit’s OCR engine allows you to recognize text and save it in a separate file where you can both search and copy and paste the text. For more information, refer to the list of supported languages.

curl -X POST http://localhost:5000/build \
  -F document=@/path/to/example-document.pdf \
  -F instructions='{
  "parts": [
    {
      "file": "document"
    }
  ],
  "output": {
    "type": "json-content",
    "keyValuePairs": true,
    "language": "english"
  }
}' \
  -o result.pdf
POST /process HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary

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

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

{
  "parts": [
    {
      "file": "document"
    }
  ],
  "output": {
    "type": "json-content",
    "keyValuePairs": true,
    "language": "english"
  }
}
--customboundary--

For more information on the /build instructions, refer to the API Reference.

Example Data Extraction Response

{
	"pages": [
		{
			"pageIndex": 0,
			"keyValuePairs": [
				{
					"confidence": 95.4,
					"key": {
						"bbox": {
							"left": 0,
							"top": 0,
							"width": 100,
							"height": 100
						},
						"content": "IBAN"
					},
					"value": {
						"bbox": {
							"left": 0,
							"top": 0,
							"width": 100,
							"height": 100
						},
						"content": "FR7611808009101234567890147",
						"dataType": "String"
					}
				}
			]
		}
	]
}