This action optimizes PDF files using Ghostscript, verifies their integrity, and provides file size metrics. It's primary purpose is to serve Rule Book Rewrite and Fan-Made Mission Book repositories, although it should work with any PDF file built in the CI.
Action releases are versioned to match the upstream Ghostscript release they ship.
- uses: qwrtln/optimize-pdf@v10.07
with:
# Input PDF file path.
# Required.
file-name:
# Output file path.
# Optional. If not specified, the input file will be overwritten.
output-file:
# Ghostscript quality level for optimization.
# Options: "screen", "ebook", "printer", "prepress", "default"
# Optional. Defaults to "prepress".
quality-level:
# Text string to search for in the optimized PDF to verify CMap integrity.
# This helps detect issues that can occur with Ghostscript 10.04 in LuaLaTeX-generated PDFs.
# Optional. CMap integrity check is skipped if not specified.
test-string:
# Convert colors to CMYK color space for printing.
# Optional. Defaults to "false".
convert-to-cmyk: | Output | Description |
|---|---|
page-count |
Number of pages in the optimized PDF |
screen: Low-resolution output (72 dpi) with maximum compressionebook: Medium-resolution output (150 dpi) with medium compressionprinter: High-resolution output (300 dpi) with less compressionprepress: High-resolution output (300 dpi) with minimal compression, preserving color accuracydefault: Uses default Ghostscript settings
- name: Checkout
uses: actions/checkout@v6
- name: Optimize PDF
uses: qwrtln/optimize-pdf@v10.07
with:
file-name: 'documentation.pdf'- name: Optimize PDF with Verification
id: optimize
uses: qwrtln/optimize-pdf@v10.07
with:
file-name: 'documentation.pdf'
output-file: 'documentation-optimized.pdf'
quality-level: 'ebook'
test-string: 'Copyleft 2025'
convert-to-cmyk: 'true'
- name: Use optimization results
run: |
echo "The optimized PDF has ${{ steps.optimize.outputs.page-count }} pages"