Skip to content

Instantly share code, notes, and snippets.

@ushitora-anqou
Created December 23, 2021 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ushitora-anqou/4567a7f391c223815e15cab95d7d479d to your computer and use it in GitHub Desktop.
Save ushitora-anqou/4567a7f391c223815e15cab95d7d479d to your computer and use it in GitHub Desktop.
Split 4-slide pages into separate ones
#!/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