Last active
July 24, 2021 22:42
-
-
Save meniluca/85e4a30ae886ae7d0fbccd86d520a43d to your computer and use it in GitHub Desktop.
Revisions
-
Luca Menichetti revised this gist
Jul 24, 2021 . 1 changed file with 19 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ PAGES=`pdfinfo $PDF_INPUT | grep -i pages | awk '{print $2}'` echo "contains $PAGES pages" GROUP_BY=16 echo "grouping by $GROUP_BY pages per batch" @@ -24,21 +24,25 @@ PARTS_LIST="" for i in $(seq 0 $loops) do echo "i (batch number): $i" f=$((i*GROUP_BY+1)) if [ $f -gt $PAGES ]; then echo "Nothing left to process" break; fi echo "f (starting page for batch number $i): $f" l=$(((i+1)*GROUP_BY)) echo "l (last page for batch number $i): $l" pdfseparate -f $f -l $l $PDF_INPUT output-%d.pdf echo "pdfunite: " $(ls -1v output*) pdfunite $(ls -1v output*) part_$i.pdf rm output-* pdfbook2 --no-crop --short-edge part_$i.pdf echo "Created: part_$i-book.pdf" rm part_$i.pdf PARTS_LIST=$PARTS_LIST" part_$i-book.pdf" done echo "pdfunite " $PARTS_LIST echo "writing $PDF_OUTPUT" pdfunite $PARTS_LIST $PDF_OUTPUT -
Luca Menichetti revised this gist
Jul 24, 2021 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -24,17 +24,17 @@ PARTS_LIST="" for i in $(seq 0 $loops) do echo "i (batch number): $i" f=$((i*GROUP_BY+1)) echo "f (starting page for batch number $i): $f" l=$(((i+1)*GROUP_BY)) echo "l (last page for batch number $i): $l" pdfseparate -f $f -l $l $PDF_INPUT output-%d.pdf echo "pdfunite: " $(ls -1v output*) pdfunite $(ls -1v output*) part_$i.pdf rm output-* pdfbook2 --no-crop --short-edge part_$i.pdf echo "Created: part_$i-book.pdf" rm part_$i.pdf PARTS_LIST=$PARTS_LIST" part_$i-book.pdf" done -
Luca Menichetti revised this gist
Jul 24, 2021 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,8 @@ set -u # requires pdfinfo pdfseparate pdfunite pdfbook2 PDF_INPUT=$1 PDF_OUTPUT=$2 @@ -32,7 +34,7 @@ do echo "pdfunite: " $(ls -1v output*) pdfunite $(ls -1v output*) part_$i.pdf rm output* pdfbook2 --no-crop --short-edge part_$i.pdf rm part_$i.pdf PARTS_LIST=$PARTS_LIST" part_$i-book.pdf" done -
Luca Menichetti created this gist
Jul 24, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ #!/bin/bash set -u PDF_INPUT=$1 PDF_OUTPUT=$2 echo "converting $PDF_INPUT" echo "writing output file: $PDF_OUTPUT" PAGES=`pdfinfo $PDF_INPUT | grep -i pages | awk '{print $2}'` echo "contains $PAGES pages" GROUP_BY=20 echo "grouping by $GROUP_BY pages per batch" loops=$((PAGES/GROUP_BY)) PARTS_LIST="" for i in $(seq 0 $loops) do if [ $i -gt 2 ]; then break; fi echo "i: $i" f=$((i*GROUP_BY+1)) echo "f: $f" l=$(((i+1)*GROUP_BY)) echo "l: $l" pdfseparate -f $f -l $l $PDF_INPUT output-%d.pdf echo "pdfunite: " $(ls -1v output*) pdfunite $(ls -1v output*) part_$i.pdf rm output* pdfbook2 --short-edge part_$i.pdf rm part_$i.pdf PARTS_LIST=$PARTS_LIST" part_$i-book.pdf" done echo "pdfunite " $PARTS_LIST pdfunite $PARTS_LIST $PDF_OUTPUT