# Extract text from PDF: web app, CLI, MCP and C#
## What it does
Extracts the textual content of a PDF document. The tool can return the text in a clean “Pure” format or keep the original layout in “Raw” mode. It also supports OCR for scanned PDFs.
## Inputs and limits
* Input: a PDF file uploaded through the web page, supplied via a public URL for MCP, or placed in the task input folder for CLI and C# samples.  
* Optional parameter `textFormattingMode` (MCP only): `Pure` for cleaned text, `Raw` to preserve original formatting.  
* No explicit size limits are documented; the underlying Documentize engine processes any readable PDF.
## Web app
The page asks you to upload a PDF file, optionally indicate if it is scanned, and choose a document language for OCR. After uploading, the service extracts the text and provides a downloadable result file.  
Client configuration (the key comes from your Documentize account):

```json
{
  "mcpServers": {
    "documentize": {
      "url": "https://api.documentize.app/mcp",
      "headers": {
        "Authorization": "Bearer dmk_YOUR_KEY_HERE"
      }
    }
  }
}
```

Tool call (`tools/call`). The tool returns a task id; poll `get_task_status` until it reports 200, then download the file from `uploadFileName`:

```json
{
  "name": "extract_text",
  "arguments": {
    "fileUrl": "https://www.irs.gov/pub/irs-pdf/f8949.pdf"
  }
}
```
## Command line (CLI)
The Documentize.ExtractText CLI plugin reads PDF files placed in a task‑specific input folder and writes the extracted text to a matching output folder. It requires a task identifier but takes no other command‑line options.  
```bash
# Linux / macOS (needs the .NET 10 runtime and documentize.lic next to the DLL)
export PLUGIN_INPUT_DIR=./work/input
export PLUGIN_OUTPUT_DIR=./work/output
mkdir -p "$PLUGIN_INPUT_DIR/job1"
cp cv.pdf "$PLUGIN_INPUT_DIR/job1/"
dotnet Documentize.ExtractText.dll --task-id job1
ls "$PLUGIN_OUTPUT_DIR/job1"
```

```powershell
# Windows PowerShell
$env:PLUGIN_INPUT_DIR  = "$PWD\work\input"
$env:PLUGIN_OUTPUT_DIR = "$PWD\work\output"
New-Item -ItemType Directory -Force "$env:PLUGIN_INPUT_DIR\job1" | Out-Null
Copy-Item cv.pdf "$env:PLUGIN_INPUT_DIR\job1\"
dotnet Documentize.ExtractText.dll --task-id job1
Get-ChildItem "$env:PLUGIN_OUTPUT_DIR\job1"
```
## MCP
The hosted MCP service runs the **ExtractText** tool. Provide a public URL of the PDF with the required `fileUrl` parameter. Optionally set `textFormattingMode` to `Pure` or `Raw`. The service returns a task ID and, when complete, a text file containing the extracted content.  
Client configuration (the key comes from your Documentize account):

```json
{
  "mcpServers": {
    "documentize": {
      "url": "https://api.documentize.app/mcp",
      "headers": {
        "Authorization": "Bearer dmk_YOUR_KEY_HERE"
      }
    }
  }
}
```

Tool call (`tools/call`). The tool returns a task id; poll `get_task_status` until it reports 200, then download the file from `uploadFileName`:

```json
{
  "name": "extract_text",
  "arguments": {
    "fileUrl": "https://www.irs.gov/pub/irs-pdf/f8949.pdf"
  }
}
```
## Aspose.PDF.FOSS (C#)
A C# program using Aspose.PDF.FOSS reads a PDF file from the input folder, extracts all text with `TextAbsorber`, and writes it to `extracted.txt` in the output folder.  
```csharp
#:package Aspose.PDF.FOSS@26.11.0

using System;
using System.IO;
using System.Linq;
using Aspose.Pdf;
using Aspose.Pdf.Text;

var inputDir = args[0];
var outputDir = args[1];
var pdfPath = Directory.GetFiles(inputDir, "*.pdf").FirstOrDefault();
if (pdfPath == null) {
    Console.Error.WriteLine("No PDF found");
    Environment.Exit(1);
}
var doc = new Document(pdfPath);
var absorber = new TextAbsorber();
doc.Pages.Accept(absorber);
Directory.CreateDirectory(outputDir);
File.WriteAllText(Path.Combine(outputDir, "extracted.txt"), absorber.Text);
Console.WriteLine("extracted.txt written");
```

Save it as `app.cs` and run `dotnet run app.cs -- ./in ./out` (.NET 10 SDK).

## Verified

Every code sample on this page was run on 2026-11-03 and its result was checked:

- Extract text via MCP with check (hosted MCP server): passed in 11 s
- Extract text via CLI plugin from CV (CLI plugin): passed in 3 s
- Extract text via Aspose.PDF.FOSS C# with check (Aspose.PDF.FOSS): passed in 5 s
