---
name: "pdf123-replace-invert-color"
description: "Invert colors or replace the color scheme of a PDF for high contrast. Runs the PDF123 \"Replace & Invert Colors\" tool (pdf123.xyz) over its REST API with curl, no account needed. Use when the user wants this done to their file. Also known as: 反色与换色, Invertir y cambiar colores, रंग पलटें और बदलें, عكس الألوان واستبدالها, Inverter e trocar cores, Balik dan ganti warna, Inverser et remplacer les couleurs, Инверсия и замена цвета, 色の反転と置換, Farben umkehren, 색 반전·바꾸기, Đảo màu và đổi màu, Renkleri ters çevir ve değiştir, 反色與換色, Inverti e cambia colori, กลับสีและเปลี่ยนสี, Odwróć i zamień kolory, Інверсія та заміна кольорів, Kleuren omkeren, Ganti dan songsangkan warna, Invertera färger, Αντιστροφή και αλλαγή χρωμάτων, Обръщане и смяна на цветове, Inverteix i canvia colors, Geuza na badilisha rangi."
compatibility: "Needs curl 7.76+ and outbound HTTPS to pdf123.xyz, or PDFX_API_BASE pointing at a self-hosted pdfx-server."
---

# Replace & Invert Colors (PDF123)

Invert colors or replace the color scheme of a PDF for high contrast.

Web version: https://pdf123.xyz/replace-invert-color · All tools: https://pdf123.xyz/skills/pdf123.md

## When to use

- Turn a white-background deck into a dark, low-glare copy
- Prepare a high-contrast print for a low-vision reader
- Convert a colour report to grayscale before a mono print run

## Run it

Replace the sample file names and values with the user's, then run:

```bash
API="${PDFX_API_BASE:-https://pdf123.xyz}"
curl -sS --fail-with-body -X POST "$API/api/v1/misc/replace-invert-pdf" \
  -F "fileInput=@input.pdf" \
  -F "replaceAndInvertOption=HIGH_CONTRAST_COLOR" \
  -F "highContrastColorCombination=WHITE_TEXT_ON_BLACK" \
  -F "customColor=#000000" \
  --output-dir "pdf123-output/$(date +%Y%m%d-%H%M%S)" --create-dirs -OJ -w '%{filename_effective} %{content_type}\n'
```

## Inputs

Everything is `multipart/form-data`. The command above already sends each field with its default; keep them all and change only the values the user asked for, since some endpoints reject a missing optional field.

| Field | Type | Required | Default | Notes |
| --- | --- | --- | --- | --- |
| `fileInput` | file | yes | | .pdf (one file) |
| `replaceAndInvertOption` | choice | no | `HIGH_CONTRAST_COLOR` | Color transform. One of: `HIGH_CONTRAST_COLOR` (High contrast), `FULL_INVERSION` (Full inversion), `COLOR_SPACE_CONVERSION` (Color space conversion), `CUSTOM_COLOR` (Custom color) |
| `highContrastColorCombination` | choice | no | `WHITE_TEXT_ON_BLACK` | Contrast combination. One of: `WHITE_TEXT_ON_BLACK` (White text on black), `BLACK_TEXT_ON_WHITE` (Black text on white), `YELLOW_TEXT_ON_BLACK` (Yellow text on black), `GREEN_TEXT_ON_BLACK` (Green text on black) |
| `customColor` | color (#rrggbb) | no | `#000000` | Color |

## Result

curl saves the result in a new `pdf123-output/<timestamp>/` directory under the server's file name and prints its path and content type. Several output files come back as one ZIP. Tell the user where the file is.

## Limits

- A colour rewrite, not an accessibility audit: check the result before publishing
- High contrast and custom colour recolour fills as well as text; check pages with coloured backgrounds
- Grayscale mode needs Ghostscript; the endpoint returns 503 without it
- Password-protected files need the password; API callers run Unlock first
- Upload limit on this website: 500 MB per file, sent in chunks above about 95 MB. A single direct API request body is capped at 100 MB.

## Errors

- A non-zero curl exit means the request failed. The saved file then holds `application/problem+json`; read it and report its `detail` to the user instead of retrying blindly.
- `413`: the upload exceeds 100 MiB. `429`: wait for `Retry-After` seconds, then retry once.
- Send `X-API-KEY: $PDFX_API_KEY` only if the user has a PDF123 API key; anonymous calls work without it.

## Privacy

Files are uploaded to the API host, processed, and deleted once the response is sent. For confidential files, ask before uploading, or use a self-hosted server via `PDFX_API_BASE`.
