extractEbook.sh

#!/bin/bash

# install
# apt-get install pdftk

FILE=$1
PAGES=$2
OUT=$3

COVER=/media/lagerliste/vorlagen/ebook/cover.pdf

# check if file already exists
if [ -f ${OUT} ]; then
echo "${OUT} already exists"
exit 0
fi

# get pages
pdftk A=${COVER} B="${FILE}" cat A1 B${PAGES} output /tmp/pdftk.out.pdf

# reduce image resolution
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -sOutputFile="${OUT}" -f /tmp/pdftk.out.pdf

# view
if [ -n ${DISPLAY} ]; then
evince "${OUT}"
fi

# USAGE
# ./mkEbook.sh s02_s201.pdf 1-3 ../ebook/l83_1.1_antike.pdf