---
title: Paper Form Data Extraction
product: Form Library
description: If you have a scanned paper form or a completed PDF, instead of manually copying each answer into a digital form, you can use the AI Form Response Extractor. This plugin uses AI to extract data from filled-out paper forms, form images and PDFs.
framework: React
source: https://surveyjs.io/form-library/examples/extract-data-from-paper-forms-pdf/reactjs
index: https://surveyjs.io/form-library/examples/overview.md
---

# Paper Form Data Extraction (React)

SurveyJS provides an MIT-licensed plugin&mdash;[AI Form Response Extractor](https://github.com/surveyjs/ai-form-response-extractor)&mdash;that helps extract structured data from completed paper forms, scanned documents, and digital PDFs using AI. Given a filled-out form (as an image or PDF) and a SurveyJS JSON schema, the tool automatically maps detected values into the corresponding fields. This demo showcases the workflow in action: select and configure an LLM, upload a scanned image or PDF, and provide a JSON schema. The model then returns extracted answers aligned with that schema, which are rendered in a regular SurveyJS form for review and correction before submission.

## Configure an LLM Provider

Data extraction is powered by an LLM of your choice. In this demo, you can switch between OpenAI and Anthropic. API keys are preconfigured for demonstration purposes; however, when integrating into your own application, you must supply your own keys via environment variables.

## Provide a Form JSON Schema

The schema defines the target structure for extracted data. Each question's [`name`](https://surveyjs.io/form-library/documentation/api-reference/question#name) becomes a key in the resulting data object, while the [`title`](https://surveyjs.io/form-library/documentation/api-reference/question#title) provides a human-readable cue to help the model interpret the form.

Additionally, both individual fields and the form itself can include an `aiHint` property, which gives the model extra context about the expected content. This property is used only by the AI and is not visible in the rendered form.

```js
{
  "aiHint": "This form contains basic personal identification fields including full name, date of birth, and contact email.",
  "elements": [
    {
      "type": "text",
      "name": "fullName",
      "title": "Full name",
      "aiHint": "Person's full legal name. May appear as a single line or split into first/middle/last name. Preserve original order and capitalization."
    },
    {
      "type": "text",
      "name": "dateOfBirth",
      "title": "Date of birth",
      "inputType": "date",
      "aiHint": "Person's date of birth. Look for common formats such as DD/MM/YYYY, MM/DD/YYYY, or YYYY-MM-DD. Normalize only if explicitly required by output schema."
    },
    {
      "type": "text",
      "name": "email",
      "title": "Email address",
      "inputType": "email",
      "aiHint": "Contact email address. Must include '@' and domain. Extract exactly as shown without modification or validation correction."
    }
  ]
}
```

## Review the Extracted Data

The extracted output is returned as a plain JavaScript object whose keys correspond to the question `name` values in the schema. To display the results in an editable SurveyJS form, assign this object to the `SurveyModel`'s [`data`](/form-library/documentation/api-reference/survey-data-model#data) property:

```js
import { Model } from "survey-core";

const survey = new Model(surveyJson);
survey.data = extractedData;
```

Because the result is rendered as a standard SurveyJS survey, you automatically get built-in validation, conditional logic, and theming. Users can correct any misread or incomplete fields before final submission.

For more implementation details and source code, see the following GitHub repository:

[AI Form Response Extractor Demo](https://github.com/surveyjs/ai-form-response-extractor-demo (linkStyle))

## See Also

Paper form extraction is part of a broader workflow that unifies data collection across paper and digital channels. For more context, see the following help topic:

[Hybrid Paper and Digital Form Data Collection](/documentation/combine-paper-and-online-survey-form-data (linkStyle))

## Files

### `public/index.html`

```html
<div id="surveyElement" style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; min-height: 100%; height:100%"></div>
```

### `src/SurveyComponent.jsx`

```js
import React from "react";
import { Model } from "survey-core";
import { Survey } from "survey-react-ui";
import "survey-core/survey-core.min.css";
import "./index.css";
import { json } from "./json";

function SurveyComponent() {
    const survey = new Model(json);
    survey.onComplete.add((sender, options) => {
        console.log(JSON.stringify(sender.data, null, 3));
    });
    return (<Survey model={survey} />);
}

export default SurveyComponent;
```

### `src/index.css`

```css
/* You can add your custom CSS here. */
```

### `src/index.js`

```js
import React from "react";
import { createRoot } from "react-dom/client";
import SurveyComponent from "./SurveyComponent";

const root = createRoot(document.getElementById("surveyElement"));
root.render(<SurveyComponent />);
```

### `src/json.js`

```js
export const json = {};
```

### `src/theme.js`

```js
export const themeJson = {};
```

### `package.json`

```json
{
  "dependencies": {
    "react": "latest",
    "react-dom": "latest",
    "survey-core": "latest",
    "survey-react-ui": "latest"
  },
  "devDependencies": {
    "react-scripts": "latest"
  }
}
```

## Other Frameworks

- [Angular](https://surveyjs.io/form-library/examples/extract-data-from-paper-forms-pdf/angular.md)
- [Vue 3](https://surveyjs.io/form-library/examples/extract-data-from-paper-forms-pdf/vue3js.md)
- [jQuery](https://surveyjs.io/form-library/examples/extract-data-from-paper-forms-pdf/jquery.md)
- [Vanilla JS](https://surveyjs.io/form-library/examples/extract-data-from-paper-forms-pdf/vanillajs.md)
