Skip to content

Instantly share code, notes, and snippets.

@kwharrigan
Last active November 4, 2024 20:49
Show Gist options
  • Save kwharrigan/7485294 to your computer and use it in GitHub Desktop.
Save kwharrigan/7485294 to your computer and use it in GitHub Desktop.
A simple script to form a multipage PDF using scanimage / sane. It is hard-coded to my MF4270 device id as provided by scanimage -L.
outname=$1
startdir=$(pwd)
tmpdir=scan-$RANDOM
DEVICENAME=pixma:04A926B5_SFF780310398A
if [ $# -lt 1 ]
then
echo "Usage: scan.sh <filename.pdf>"
exit 1;
fi
cd /tmp
mkdir $tmpdir
cd $tmpdir
echo "################## Scanning ###################"
scanimage -d $DEVICENAME --source "Automatic Document Feeder" --mode Gray --batch --format=tiff --resolution 150
echo "############## Converting to PDF ##############"
#Use tiffcp to combine output tiffs to a single mult-page tiff
tiffcp -c lzw out*.tif output.tif
#Convert the tiff to PDF
tiff2pdf output.tif > $startdir/$outname
cd ..
echo "################ Cleaning Up ################"
#rm -rf $tmpdir
cd $startdir
@0guzhan
Copy link

0guzhan commented Dec 10, 2017

it helped, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment