---
name: "ghostscript-pdf-compression"
description: "Shrink oversized PDF file sizes and repair corrupted font encodings using Ghostscript."
metadata:
  author: "Artifex"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "compress large pdf ghostscript"
  - "optimize pdf for web fast view"
  - "repair damaged pdf file"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Ghostscript PDF Compression & Repair

Optimizes PDF document sizes via Ghostscript gs CLI: downsampling images (ebook, screen, prepress settings), linearizing for web fast-view, and repairing broken cross-reference tables.

## When to Invoke
Invoke this skill whenever you need to:
- compress large pdf ghostscript
- optimize pdf for web fast view
- repair damaged pdf file

## Execution SOP & Rules
1. Run gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH.
2. Select /screen (72dpi), /ebook (150dpi), or /prepress (300dpi) according to output needs.
3. Use qpdf --linearize on the compressed file to optimize byte-serving for web view.
4. Verify visual readability of fine text and table lines after image downsampling.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
