# Chat with AI to generate PDF: web app and CLI

## What it does
The Chat feature lets you send a natural‑language request to an LLM. The model reads any uploaded PDF for context, answers the prompt, and returns the result as a formatted PDF document. You can continue the conversation to edit, expand, or refine the PDF.

## Inputs and limits
* Input: a text prompt (required).  
* Optional: a single PDF file uploaded for context.  
* The generated PDF is returned for download. Files are kept only for the current task and then removed.

## Web app
The page asks for a text prompt and optionally lets you upload a PDF. After submission, the AI processes the request, creates a structured PDF, and provides a download link. You can edit the PDF and continue the chat to have the AI update the document in later turns.

## Command line (CLI)
The CLI plugin runs without a GUI. It reads the prompt from `--query` and writes the response 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.Chat.dll --task-id job1 --query "Summarize the dummy PDF"
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.Chat.dll --task-id job1 --query "Summarize the dummy PDF"
Get-ChildItem "$env:PLUGIN_OUTPUT_DIR\job1"
```

## Verified

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

- Chat CLI sample (CLI plugin): passed in 15 s
