Created
September 21, 2015 14:08
-
-
Save danman01/901ad45c21f9c186db37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
pdf_stylesheet="/Users/dkirschner/dev/mapr/apache_spark/ebook/spark-book-theme/pdf/pdf.css" | |
theme_stylesheet="/Users/dkirschner/dev/mapr/apache_spark/ebook/spark-ebook/theme/pdf/pdf.css" | |
print_stylesheet="/Users/dkirschner/dev/mapr/apache_spark/ebook/spark-book-theme/pdf/pdf_print.css" | |
USAGE="Usage: -f input file with html ending, -p anything here will turn on print mode, -? or -h prints usage" | |
while getopts “ht:f:p” OPTION | |
do | |
case $OPTION in | |
h) | |
echo $USAGE | |
exit 1 | |
;; | |
f) | |
html=$OPTARG | |
;; | |
p) | |
PRINT=1 | |
;; | |
?) | |
echo $USAGE | |
exit | |
;; | |
esac | |
done | |
if [[ -z $html ]] | |
then | |
echo $USAGE | |
exit 1 | |
fi | |
# convert supplied html file to html using prince | |
pdf=$(echo "$html" | sed 's/html/pdf/') | |
echo "pdf file is going to be $pdf" | |
# convert html to pdf | |
if [ -z $PRINT ] | |
then | |
echo "generating web version of pdf..." | |
prince $html -o $pdf -s $pdf_stylesheet -s $theme_stylesheet | |
else | |
echo "generating print version of pdf..." | |
prince $html -o $pdf -s $pdf_stylesheet -s $theme_stylesheet -s $print_stylesheet | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment