Skip to content

Commit

Permalink
option to control pdf image quality
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandreaquiles committed Feb 2, 2016
1 parent 59e0fa7 commit 1e8eba0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tubaina2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function show_help {
echo " -native runs outside Docker (optional, default runs inside Docker)"
echo " -dockerImage repo/image (optional, default casadocodigo/gitbook)"
echo " -imageRootFolder folder/ (optional)"
echo " -pdfImageQuality <default, screen, ebook, printer or prepress> (optional, default prepress)"
echo " -help print usage"
echo
echo "On your book source folder, add a book.properties with optional book configurations:"
Expand All @@ -36,7 +37,7 @@ if [ ! -d "$SRCDIR" ]; then
exit 1
fi

OPTS=`getopt -a -l dockerImage: -l showNotes -l native -l html -l epub -l mobi -l pdf -l ebooks -l imageRootFolder: -l help -n 'tubaina2' -- "$0" "$@"`
OPTS=`getopt -a -l dockerImage: -l showNotes -l native -l html -l epub -l mobi -l pdf -l ebooks -l imageRootFolder: -l pdfImageQuality: -l help -n 'tubaina2' -- "$0" "$@"`
if [ $? != 0 ] ; then echo; show_help; exit 1 ; fi
eval set -- "$OPTS"

Expand All @@ -49,12 +50,21 @@ while true; do
--native) NATIVE=true; shift;;
--html|--epub|--mobi|--pdf|--ebooks) OUTPUT_FORMAT="$1"; shift;;
--imageRootFolder) IMAGE_ROOT_FOLDER=$2; shift 2;;
--pdfImageQuality) PDF_IMAGE_QUALITY=$2; shift 2;;
--help) show_help; exit 0;;
--) shift; break;;
* ) break ;;
esac
done

PDF_IMAGE_QUALITY_VALUES=(default screen ebook printer prepress)
if [[ ${PDF_IMAGE_QUALITY} && ! " ${PDF_IMAGE_QUALITY_VALUES[@]} " =~ " ${PDF_IMAGE_QUALITY} " ]]; then
echo "Error: Invalid -pdfImageQuality. Can be: ${PDF_IMAGE_QUALITY_VALUES[*]}"
exit 1
fi
#default value
: ${PDF_IMAGE_QUALITY:=prepress}

echo "[tubaina] Using docker image: $DOCKER_IMAGE"

echo "[tubaina] Generating book from $SRCDIR"
Expand Down Expand Up @@ -255,6 +265,7 @@ function generate_book_json {
"firstChapter": "${first_chapter%.*}",
"numIntroChapters": $num_intro_chapters,
"partHeaders": [${PART_HEADERS[*]}],
"pdfImageQuality": "$PDF_IMAGE_QUALITY",
"plugins": ["cdc", "$THEME"]
Expand Down

0 comments on commit 1e8eba0

Please sign in to comment.