Skip to content

Commit

Permalink
add generic pdf conversion for convert_multipge
Browse files Browse the repository at this point in the history
  • Loading branch information
yaswant committed Jan 28, 2020
1 parent 7457530 commit cfd23e0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions convert_multipage
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# users sharing same path at same time which may result permission
# error. YP.
# May 2019 PDF to grey PDF.
# Jan 2020 joinpdf depends on joinpdf script to avoid single dependency iof pdftk
# ----------------------------------------------------------------------------
set -e

Expand Down Expand Up @@ -285,8 +286,8 @@ else
fi

## Copy or extract selected pages to a temporary PS file ---------------------
if (( extract == 1 )); then
psselect "$PSOPT1" -q "$FILE" "$TMPS1"
if (( extract )); then
psselect $PSOPT1 -q "$FILE" "$TMPS1"
else
cp "$FILE" "$TMPS1"
fi
Expand Down Expand Up @@ -314,7 +315,8 @@ pnum=
while (( PAGE <= NPAGES )); do
## Select ps pages and write to temp file --------------------------------
# [[ $NPAGES -gt 1 ]] && pnum="-$(printf '%s %s' $Z $PAGE)"
(( NPAGES > 1 )) && pnum="-$(printf '%s %s' $Z $PAGE)"
#(( NPAGES > 1 )) && pnum="-$(printf '%s %s' $Z $PAGE)"
(( NPAGES > 1 )) && pnum="-$(printf $Z $PAGE)"
psselect $PSOPT2 -p$PAGE "$TMPS1" "$TMPS2"

if [[ $OFMT == pdf ]]; then
Expand Down Expand Up @@ -368,7 +370,9 @@ while (( PAGE <= NPAGES )); do

if [[ $OFMT = pdf ]] && [[ $PDFJOIN = T ]] ; then
echo -e "INFO: Joining PDF pages.. \c"
pdftk "$pdfPages" cat output "${OUTFILE}.${OFMT}"
# pdftk "$pdfPages" cat output "${OUTFILE}.${OFMT}"
joinpdf "$pdfPages" "${OUTFILE}.${OFMT}"

echo -e "done."
rm -f ${OUTFILE}-*.${OFMT}
fi
Expand Down

0 comments on commit cfd23e0

Please sign in to comment.