Created
December 23, 2021 09:13
-
-
Save ushitora-anqou/4567a7f391c223815e15cab95d7d479d to your computer and use it in GitHub Desktop.
Split 4-slide pages into separate ones
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
#!/usr/bin/bash | |
# | |
# 0 -1 -348 | |
# -->| | |
# ----------------------->| | |
# | |
# +----------+ +----------+ | |
# | | | | | |
# | SLIDE #1 | | SLIDE #2 | | |
# | | | | | |
# +----------+ +----------+<---------- | |
# -45 0 | |
# -393 | |
# |<------------------------------- | |
# | |
# 0 | | | |
# | | | |
# v | | |
# -1 - | +----------+ | |
# | | | | |
# | | SLIDE #1 | | |
# | | | | |
# | +----------+ - -319 | |
# v ^ | |
# -251 - +----------+ | | |
# | | | | |
# | SLIDE #3 | | | |
# | | | | |
# +----------+ -68 - | | |
# ^ | | |
# | | 0 | |
SRCNAME=$1 | |
OUTNAME=$2 | |
TMPDIR=tmp | |
rm -rf $TMPDIR | |
mkdir $TMPDIR | |
pdfseparate $SRCNAME "$TMPDIR/$SRCNAME-%d.pdf" | |
ls $TMPDIR/$SRCNAME-*.pdf | while read line; do | |
pdfcrop --margins '-1 -1 -393 -319' $line $line-1.pdf | |
pdfcrop --margins '-348 -1 -45 -319' $line $line-2.pdf | |
pdfcrop --margins '-1 -251 -393 -68' $line $line-3.pdf | |
pdfcrop --margins '-348 -251 -45 -68' $line $line-4.pdf | |
done | |
pdfunite $TMPDIR/$SRCNAME-*.pdf-*.pdf $OUTNAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment