# Resize PDF pages: web app, CLI, MCP and C# (FOSS)
## What it does
Resizes all pages of a PDF document to a chosen standard page size (e.g., A4, Letter, A3). The operation is applied to the whole document; per‑page size selection is not supported.

## Inputs and limits
* Input: a single PDF file provided via upload (web), URL (MCP), or placed in the input folder (CLI, C#).  
* Supported page sizes: standard sizes such as A4, Letter, A3, Legal; the CLI and MCP also accept a custom string for other sizes.  
* The web service stores files for 24 hours and enforces the platform’s upload size limit.

## Web app
The page at **/app-prod/resize-pdf** asks you to upload a PDF, then select a target page size or enter a scaling percentage. After processing, the resized PDF can be downloaded.

## Command line (CLI)
The Documentize.Resize CLI plugin reads a PDF from a per‑task input folder and writes the resized PDF to the matching output folder.  
Key option: `--target-page-size <size>` (default **A4**).  
```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.Resize.dll --task-id job1 --target-page-size A4
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.Resize.dll --task-id job1 --target-page-size A4
Get-ChildItem "$env:PLUGIN_OUTPUT_DIR\job1"
```

## MCP
The hosted MCP tool **ResizeDocument** resizes a PDF reachable at a public URL.  
Required parameter: `fileUrl` – the URL of the PDF.  
Optional parameter: `targetPageSize` – page size name (e.g., A4).  
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": "resize_document",
  "arguments": {
    "fileUrl": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
    "targetPageSize": "A4"
  }
}
```

## Aspose.PDF.FOSS (C#)
The Aspose.PDF.FOSS library can resize pages by setting each page’s size to A4 (or any other size). The sample processes all PDFs found in the input folder.  
```csharp
#:package Aspose.PDF.FOSS@26.11.0

using Aspose.Pdf;
using System.IO;

var inputDir = args[0];
var outputDir = args[1];
foreach (var file in Directory.GetFiles(inputDir, "*.pdf"))
{
    var doc = new Document(file);
    foreach (Page page in doc.Pages)
    {
        // A4 size in points (1 point = 1/72 inch) approx 595 x 842
        page.SetPageSize(595, 842);
    }
    var outPath = Path.Combine(outputDir, Path.GetFileName(file));
    doc.Save(outPath);
    System.Console.WriteLine($"Resized {Path.GetFileName(file)}");
}
```

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:

- Resize CLI sample (CLI plugin): passed in 5 s
- Resize MCP sample (hosted MCP server): passed in 13 s
- Resize C# foss sample (Aspose.PDF.FOSS): passed in 6 s
