# Extract Text — LLMWhisperer

> Convert your PDF/scanned documents to text format which can be used by LLMs. See the documentation

- Key: `llmwhisperer-extract-text`
- Type: Action (Read-only)
- Version: 0.1.4
- App: LLMWhisperer (`llmwhisperer`) — https://pipedream.com/apps/llmwhisperer.md
- This page (HTML): https://pipedream.com/apps/llmwhisperer/actions/extract-text
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/llmwhisperer/actions/extract-text/extract-text.mjs

## Description

Convert your PDF/scanned documents to text format which can be used by LLMs. [See the documentation](https://docs.unstract.com/llm_whisperer/apis/llm_whisperer_text_extraction_api)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `processingMode` | `string` | Yes | The processing mode to be used. Choose between ocr and text. |
| `outputMode` | `string` | Yes | The output mode to be used. Choose between line-printer and text. |
| `pageSeperator` | `string` | No | The string to be used as a page separator. Eg: <<< |
| `forceTextProcessing` | `boolean` | No | If set to true, the document will be processed as text only. If set to false, the document will be processed based on LLMWhisperer's chosed stratergy. |
| `pagesToExtract` | `string` | No | Define which pages to extract. By default all pages are extracted. You can specify which pages to extract with this parameter. Example 1-5,7,21- will extract pages 1,2,3,4,5,7,21,22,23,24... till the last page. |
| `timeout` | `integer` | No | The time in seconds after which the request will automatically switch to async mode. If a timeout occurs then the API will return a 202 message along with whisper-hash which can be used later to check processing status and retrieve the text. Refer to the async operation documentation for more information |
| `storeMetadataForHighlighting` | `boolean` | No | If set to true, metadata required for the highlighting is stored. If you do not require highlighting API, set this to false. Note that setting this to true will store your text in our servers |
| `medianFilterSize` | `integer` | No | The size of the median filter to be applied to the image. This is used to remove noise from the image. This parameter works only in on-prem version of LLMWhisperer. |
| `gaussianBlurRadius` | `integer` | No | The radius of the gaussian blur to be applied to the image. This is used to remove noise from the image. This parameter works only in on-prem version of LLMWhisperer. |
| `ocrProvider` | `string` | No | The OCR provider to be used. Choose between simple and advanced. This parameter works only in on-prem version of LLMWhisperer. |
| `lineSplitterTolerance` | `string` | No | Factor to decide when to move text to the next line when it is above or below the baseline. The default value of 0.4 signifies 40% of the average character height. |
| `horizontalStretchFactor` | `string` | No | Factor by which a horizontal stretch has to applied. It defaults to 1.0. A stretch factor of 1.1 would mean at 10% stretch factor applied. Normally this factor need not be adjusted. You might want to use this parameter when multi column layouts back into each other. For example in a two column layout, the two columns get merged into one. |
| `data` | `string` | Yes | The document to process. Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/myFile.txt) |
| `syncDir` | `dir` | No | SyncDir |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "llmwhisperer",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "llmwhisperer-extract-text",
  arguments: {
    processingMode: "Processing Mode",
    outputMode: "Output Mode",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "llmwhisperer-extract-text",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    llmwhisperer: { authProvisionId: "apn_xxxxxxx" },
    processingMode: "Processing Mode",
    outputMode: "Output Mode",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "llmwhisperer-extract-text",
    "configured_props": {
      "llmwhisperer": { "authProvisionId": "apn_xxxxxxx" },
      "processingMode": "Processing Mode",
      "outputMode": "Output Mode"
    }
  }'
```

---

- App: https://pipedream.com/apps/llmwhisperer.md · All apps: https://pipedream.com/apps
