#!/bin/sh
##
##  pdfoutline -- outline a PDF document
##  Copyright (c) 2020 Dr. Ralf S. Engelschall <rse@engelschall.com>
##  Licensed under MIT license.
##

#   determine parameters
if [ $# -ne 2 ]; then
    echo "pdfoutline: USAGE: pdfoutline <input-pdf> <output-pdf>" 1>&2
    exit 1
fi
input="$1"
output="$2"

#   perform outlining with the help of Ghostscript
@l_prefix@/bin/gs \
    -q \
    -dbatch \
    -dNOPAUSE \
    -dNOCACHE \
    -dQUIET \
    -dBATCH \
    -sDEVICE=pdfwrite \
    -dSAFER \
    -dCompatibilityLevel="1.5" \
    -dPDFSETTINGS="/printer" \
    -dNoOutputFonts \
    -sOutputFile=$output \
    -f $input

