Dec
01
Un petit script per escanejar directament a PDF des d’un escaner ADF (Automàtic document feed) amb sane-utils i kdialog.
#!/bin/bash
mode=$(kdialog –menu "Selecciona el modo" a Color b Grises)
if [ $? -lt 1 ]; then
if [ $mode = a ]; then mod=Color; fi
if [ $mode = b ]; then mod=Grey; fi
outname=$(kdialog –getsavefilename $HOME/documento.pdf)
if [ $? -lt 1 ]; then
startdir=$(pwd)
tmpdir=scan
echo $mod
cd /tmp
mkdir $tmpdir
cd $tmpdir
echo "################## Scanning ###################"
scanimage –format=tiff –batch=out%d.tiff –batch-start=1 –batch-increment=1 –mode $mod –source ADF –resolution 300
if [ $? -lt 1 ]; then
echo "############## Converting to PDF ##############"
#Use tiffcp to combine output tiffs to a single mult-page tiff
tiffcp -c lzw out*.tiff output.tiff
#Convert the tiff to PDF
tiff2pdf output.tiff > $outname
cd ..
echo "################ Cleaning Up ################"
rm -rf $tmpdir
kpdf $outname
else
kdialog –msgbox "No se ha detectado ningun scanner"
fi
fi
fi
mode=$(kdialog –menu "Selecciona el modo" a Color b Grises)
if [ $? -lt 1 ]; then
if [ $mode = a ]; then mod=Color; fi
if [ $mode = b ]; then mod=Grey; fi
outname=$(kdialog –getsavefilename $HOME/documento.pdf)
if [ $? -lt 1 ]; then
startdir=$(pwd)
tmpdir=scan
echo $mod
cd /tmp
mkdir $tmpdir
cd $tmpdir
echo "################## Scanning ###################"
scanimage –format=tiff –batch=out%d.tiff –batch-start=1 –batch-increment=1 –mode $mod –source ADF –resolution 300
if [ $? -lt 1 ]; then
echo "############## Converting to PDF ##############"
#Use tiffcp to combine output tiffs to a single mult-page tiff
tiffcp -c lzw out*.tiff output.tiff
#Convert the tiff to PDF
tiff2pdf output.tiff > $outname
cd ..
echo "################ Cleaning Up ################"
rm -rf $tmpdir
kpdf $outname
else
kdialog –msgbox "No se ha detectado ningun scanner"
fi
fi
fi












Recent Comments