summaryrefslogtreecommitdiff
path: root/functions/pdfpextr.fish
diff options
context:
space:
mode:
Diffstat (limited to 'functions/pdfpextr.fish')
-rw-r--r--functions/pdfpextr.fish15
1 files changed, 15 insertions, 0 deletions
diff --git a/functions/pdfpextr.fish b/functions/pdfpextr.fish
new file mode 100644
index 0000000..a550bb3
--- /dev/null
+++ b/functions/pdfpextr.fish
@@ -0,0 +1,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