summaryrefslogtreecommitdiff
path: root/functions/pdfpextr.fish
blob: a550bb30736ac12ef365b658a1b59e4ac5890e7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function pdfpextr -a pStart pEnd filename
    # this function uses 3 arguments:
    #     $1 is the first page of the range to extract
    #     $2 is the last page of the range to extract
    #     $3 is the input file
    #     output file will be named "inputfile_pXX-pYY.pdf"
    set -l fileOut (string split -r -m1 . $filename)[1]_p{$pStart}-p{$pEnd}.pdf
    printf $fileOut

    gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER \
       -dFirstPage=$pStart \
       -dLastPage=$pEnd \
       -sOutputFile=$fileOut \
        "$filename"
end