Created
February 1, 2018 18:40
-
-
Save yuwash/51d602805b37d3f15f87d30f2ca2e0e6 to your computer and use it in GitHub Desktop.
Combine top halves of two PDF into one page, rotating the second upside-down
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/env bash | |
[[ "$#" == 2 ]] || { | |
echo Please specify the two input PDF files. | |
exit 1 | |
} | |
PDF1="$1" | |
PDF2="$2" | |
PDFALL="all-$(date -I).pdf" | |
OUTPUTPDF="topcombine-${PDF1%.pdf}-$PDF2" | |
pdftk A="$PDF1" B="$PDF2" cat A B output "$PDFALL" \ | |
&& pdftops "$PDFALL" \ | |
&& rm "$PDFALL" \ | |
&& pstops "2:0(0,-.5h)+1U(1w,1.5h)" "${PDFALL%.pdf}.ps" "${OUTPDF%.pdf}.ps" \ | |
&& rm "${PDFALL%.pdf}.ps" \ | |
&& ps2pdf "${OUTPDF%.pdf}.ps" \ | |
&& rm "${OUTPUTPDF%.pdf}.ps" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When pdftk isn’t available in more recent ubuntu repositories, you can convert both to ps first and then use
psmerge
.Update: Or better (actually simpler than
pdftk
for this use case), usepdfunite
like