Created
April 17, 2020 21:45
-
-
Save JohnAZoidberg/2ec83c2319f9a10decd8fc6ee886ef3c to your computer and use it in GitHub Desktop.
Split a scanned PDF at a separator page with a QR code
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 nix-shell | |
#! nix-shell -i bash -p zbar poppler_utils | |
# Separate PDF | |
pdfseparate scanned.pdf 'page-%02d.pdf' | |
# Combine | |
pdfs="" | |
combined=0 | |
names=( | |
"Mietvertrag" | |
"Arbeitsvertrag" | |
"Meldebestaetigung" | |
) | |
for f in page*; do | |
if zbarimg "$f" 2> /dev/null | grep -q "QR-Code:This is Daniels separator page"; then | |
pdfunite $pdfs "${names[combined]}.pdf" | |
combined=$((combined+1)) | |
pdfs="" | |
else | |
pdfs="$pdfs $f" | |
fi | |
done | |
pdfunite $pdfs "${names[combined]}.pdf" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment