# Convert PDF files: web app, CLI and MCP
## What it does
The Converter app transforms a document from one format to another. It supports conversions such as PDF → HTML and PDF → DOCX.

## Inputs and limits
* Input file: a single PDF (or other supported format) provided by upload or URL.  
* Up to 10 files per request.  
* Maximum total size per request: 32 MB.  
* The source file must match the declared input format.

## Web app
The page at **/app-prod** asks for:
* A file upload (or a URL) for the source document.  
* Selectors for **Input format** and **Output format** (e.g., PDF → HTML, PDF → DOCX).  
* An optional “Convert to single output file” checkbox.  

After submission the service converts the document and returns a download link for the result.

## Command line (CLI)
The **PdfSaveAs** plugin converts a PDF to another format.

Example command:

`dotnet Documentize.PdfSaveAs.dll --output-format docx`

The plugin reads the PDF from a task‑specific input folder and writes the DOCX file to the task’s output folder.

```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 sample.pdf "$PLUGIN_INPUT_DIR/job1/"
dotnet Documentize.PdfSaveAs.dll --task-id job1 --output-format docx
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 sample.pdf "$env:PLUGIN_INPUT_DIR\job1\"
dotnet Documentize.PdfSaveAs.dll --task-id job1 --output-format docx
Get-ChildItem "$env:PLUGIN_OUTPUT_DIR\job1"
```

## MCP
The **ConvertDocument** MCP tool converts a document from a public URL.

Required parameters:
* `fileUrl` – public URL of the source file (required)  
* `inputType` – format of the source file (e.g., `pdf`) (required)  
* `outputType` – desired output format (e.g., `html`) (required)  
* `xmlType` – optional XML variant (integer)  
* `fontSize` – optional font‑size override (integer)

The tool returns a task ID; polling `GetTaskStatus` yields the converted 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": "convert_document",
  "arguments": {
    "fileUrl": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
    "inputType": "pdf",
    "outputType": "html"
  }
}
```

## Verified

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

- Convert PDF to DOCX and verify text present (CLI plugin): passed in 10 s
- Convert PDF to HTML via MCP and verify text (hosted MCP server): passed in 6 s
