Skip to content

Instantly share code, notes, and snippets.

@fwdekker
Created February 17, 2026 10:33
Show Gist options
  • Select an option

  • Save fwdekker/0eedc32483bc490ab3b7a1903fe02173 to your computer and use it in GitHub Desktop.

Select an option

Save fwdekker/0eedc32483bc490ab3b7a1903fe02173 to your computer and use it in GitHub Desktop.
Rasterise PDF and annotations
#!/bin/sh
# Config
IN_FILE="my_file.pdf"
# Script
BASENAME="$(printf "%s" "$IN_FILE" | cut -d. -f1)"
EXTENSION="$(printf "%s" "$IN_FILE" | cut -d. -f2)"
OUT_FILE="$BASENAME.rasterised.$EXTENSION"
TMP_FILE="$(mktemp)"
convert -render -density 300 "$IN_FILE" "$TMP_FILE"
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$OUT_FILE" "$TMP_FILE"
rm -f "$TMP_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment