# Deskew PDF files: web app and CLI

## What it does
Straightens (deskews) scanned page images inside a PDF. The tool detects the rotation of each page and rotates the visual layer back to level while preserving any existing OCR/text layer.

## Inputs and limits
* Input: a PDF file (standard PDF, including encrypted PDFs with a user password).  
* Maximum file size: up to 100 MB.  
* The CLI reads the PDF from a task‑specific input folder and writes the corrected PDF to the corresponding output folder.

## Web app
The Deskew web page asks you to upload a scanned PDF (or an image converted to PDF). After upload the AI analyses each page, computes the precise rotation angle with OpenCV, corrects the skew, and returns a clean, searchable PDF. The page notes support for PDFs up to 100 MB, encrypted PDFs (with password), and that OCR layers are preserved.

## Command line (CLI)
The Deskew CLI plugin processes PDFs placed in a task folder. It requires a `--task-id` (or the runner supplies one) and reads all PDFs in `<PLUGIN_INPUT_DIR>/<task-id>/`. After processing, the corrected PDF appears in `<PLUGIN_OUTPUT_DIR>/<task-id>/`. No additional command‑line options are needed.

```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 abstracts_sample.pdf "$PLUGIN_INPUT_DIR/job1/"
dotnet Documentize.Deskew.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 abstracts_sample.pdf "$env:PLUGIN_INPUT_DIR\job1\"
dotnet Documentize.Deskew.dll --task-id job1
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:

- Deskew a PDF via CLI (CLI plugin): passed in 3 s
