-
Notifications
You must be signed in to change notification settings - Fork 0
/
make
42 lines (31 loc) · 976 Bytes
/
make
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
TEX_BIN=/cygdrive/C/texmf/miktex/bin
PDFLATEX=$TEX_BIN/pdflatex.exe
extract_page()
{
OUTPUT_NAME=$1
FIRST_PAGE=$2
LAST_PAGE=$3
gs -dFirstPage=$FIRST_PAGE \
-dLastPage=$LAST_PAGE \
-sDEVICE=pdfwrite \
-sOutputFile=$OUTPUT_NAME \
-dBATCH \
-dNOPAUSE \
bigode.pdf
}
CHAPTER_NAMES=("front_cover" "contents" "preface" "chapter0" "chapter1" "chapter2" "chapter3" "chapter4" "chapter5" "chapter6" "chapter7" "chapter8" "chapter9" "back_cover")
PAGES=(1 3 5 7 13 27 47 65 79 91 103 119 127 134 135)
ZIP_FILE=bigode.zip
rm $ZIP_FILE
$PDFLATEX bigode.tex
$PDFLATEX bigode.tex
zip -g $ZIP_FILE bigode.pdf
for (( i = 0; i < ${#CHAPTER_NAMES[@]}; i++ ))
do
CHAPTER_NAME=${CHAPTER_NAMES[i]}
CHAPTER_NUM=`echo $i | awk '{printf("%02d",$0);}'`
OUTPUT_NAME=${CHAPTER_NUM}_${CHAPTER_NAME}.pdf
extract_page $OUTPUT_NAME ${PAGES[i]} `expr ${PAGES[i+1]} - 1`
zip -g $ZIP_FILE $OUTPUT_NAME
done