Skip to content

Instantly share code, notes, and snippets.

@dettmering dettmering/diff-all.sh
Last active Jan 25, 2019

Embed
What would you like to do?
Compare a single page of two PDF files.
#!/bin/bash
FILE_A=$1
FILE_B=$2
PAGE_COUNT_A=$(pdfinfo $FILE_A | grep Pages | awk '{print $2}')
PAGE_COUNT_B=$(pdfinfo $FILE_B | grep Pages | awk '{print $2}')
if [ $PAGE_COUNT_A -eq $PAGE_COUNT_B ];
then
for i in $(seq 0 $PAGE_COUNT_A); do
echo Comparing page $i
convert -density 300 $FILE_A[$i] -transparent white -colorspace RGB -alpha extract -threshold 0 -fill red +opaque black -transparent black A.png
convert -density 300 $FILE_B[$i] -transparent white -colorspace RGB -alpha extract -threshold 0 -fill blue +opaque black -transparent black B.png
composite -blend 50 A.png B.png diff_$i.png
rm A.png B.png
done
else
echo Page count of the documents does not match.
exit 1
fi
#!/bin/bash
FILE_A=$1
FILE_B=$2
convert -density 300 $FILE_A -transparent white -colorspace RGB -alpha extract -threshold 0 -fill red +opaque black -transparent black A.png
convert -density 300 $FILE_B -transparent white -colorspace RGB -alpha extract -threshold 0 -fill blue +opaque black -transparent black B.png
composite -blend 50 A.png B.png diff.png
rm A.png B.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.