52

Is there some easy to use program in Ubuntu that can scan many pages straight into a PDF file?

7 Answers7

51

The idea of having a simple scan utility was behind the development of, well, Simple Scan - the scanning tool installed by default from 10.04 on (Applications ‣ Graphics ‣ Simple Scan). alt text

Simply scan as many pages as you want and choose PDF as file format when saving.

Another slightly less simple program that offers additional features like text recognition is gscan2pdf, also in the repositories. alt text

7

"Easy to use" is in the eye of the user, but xsane provides this functionality. Choose multipage where it says viewer (or hit CTRL-M), and it shouldn't be too difficult to figure out from there.

3

I was using xsane until I saw this question and considered its interface idiosyncratic to say the least, but effective.

Upon seeing this question I went looking and found gscan2pdf living in the Ubuntu Lucid/Maverick repositories. It uses the same scanning (libsane) engine but the UI is far more Gnome-ish. For a good time, try:

sudo apt-get install gscan2pdf
msw
  • 4,696
2

Change the file name from myfile.jpg to myfile.pdf on the save dialog of Simple Scan.

Tested on Ubuntu 14.04, Simple Scan 3.12.1.

This works even though the file type drop-down does not show "PDF", only "Images". I consider this an UI bug.

This feature is documented on Help > Contents:

From the "Save As" dialog box, choose one of the supported file types, or simply change the extension in the "Name" field.

It says that the following formats are supported:

  • PDF
  • JPEG
  • PNG
  • TIFF

Interesting fact: if you change the scan type (dropdown besides "Scan") to "Text", the default file type becomes PDF.

2

Scan pages from USB scanner. Use tesseract to OCR into a PDF. Merge multiple pages into one PDF. Usage: scan2PDF outputfilename number_of_pages

#!/bin/bash
#scan2PDF
#Requires:      tesseract 3.03 for OCR to PDF
#               scanimage for scanning, I use  1.0.24
#               pdfunite to merge multiple PDF into one, I use 0.26.5
#
#       Use scanimage -L to get a list of devices.
#       e.g. device `genesys:libusb:006:003' is a Canon LiDE 210 flatbed scanner
#       then copy/paste genesys:libusb:006:003 into SCANNER below.
#       play with CONTRAST to get good images
DPI=300
TESS_LANG=nor  #Language that Tesseract uses for OCR
SCANNER=genesys:libusb:006:003  #My USB scanner
CONTRAST=35   #Contrast to remove paper look

FILENAME=$1 #Agrument 1,filename
PAGES=$2    #Argument 2, number of pages

re='^[0-9]+$'  #Check if second argument is a number
if ! [[ ${PAGES} =~ $re ]] ; then
   echo "error: Usage: $0 filename number_of_pages" >&2; exit 1
fi

SCRIPT_NAME=`basename "$0" .sh` #Directory to store temporary files
TMP_DIR=${SCRIPT_NAME}-tmp

if [ -d ${TMP_DIR} ]  #Check if it exists a directory already
then
        echo Error: The directory ${TMP_DIR} exists.
        exit 2
fi
mkdir ${TMP_DIR}  #Make and go to temp dir
cd ${TMP_DIR}

echo Starts Scanimage...
scanimage -d ${SCANNER} --format=tiff --mode Color --resolution ${DPI} -p --contrast ${CONTRAST} --batch-start=1 --batch-count=${PAGES}  --batch-prompt


echo Starts Tesseract OCR

for file in  *.tif  #Goes through every tif file in temp dir
do
        tesseract $file  ${file%.tif} -l ${TESS_LANG} pdf

done

if [ "$PAGES" = "1" ] #How many pages
then
    cp out1.pdf ../${FILENAME}.pdf  #Only one page, just copy the PDF back
else
        for file in *.pdf  #More pages, merge the pages into one PDF and copy back
    do
            pdfuniteargs+=${file} 
            pdfuniteargs+=" "
    done
    pdfunite $pdfuniteargs ../${FILENAME}.pdf
fi
    echo ${FILENAME}.pdf done

rm *                    #Done, clean up
cd ..
rmdir ${TMP_DIR}
morten
  • 29
0

For those of you wishing to use XSANE. It is very powerful, and intuitive once you read the setup guide linked from Help > XSane Doc in the program - to know how much you can do with it. It's also worth checking your SANE backend is working properly (not too Arch specific): https://wiki.archlinux.org/index.php/SANE

If you want to automatically scan documents from a feeder, and wonder if XSane will know when to stop (and not stop too early), simply input a number at the top left (number of scans icon) larger than the number of pages that fit in your feeder. I.e. if your feeder can take 10 pages, then enter 15 (to account for thickness variation). If you have a duplex scanner, double this number.

When the feeder runs out, you will get a dialog box with a green warning triangle saying ""Scanned pages: 0". This just means that the feeder is empty and you can close the dialog. If you selected "viewer" or "save" at the top right of XSane, then the files will all be there - remember to save them from the viewer. Now you can press scan again to carry on where you left off, with the numbers incrementing from the same point or you can start a new project. There will not be any blank pages added. If you selected "Multipage" the project dialog should show all the completed scans and you can click to save as a multipage PDF or TIFF or PostScript.

HTH,

DC

0

I wrote a short script to do the whole thing. It uses fish, sane's scanimage and imagemagick's magick.

#!/usr/bin/fish

set n $argv[1] set out $argv[2]

set device_name (scanimage -f %d%n | grep -v v4l)

set tmpd (mktemp -d) for i in (seq 1 $n) read --prompt-str 'Hit enter to start the next scan.' scanimage --device-name $device_name --resolution 300 -x 210mm -y 297mm --format jpeg --mode color >$tmpd/$i.jpg end magick $tmpd/* $out rm -r $tmpd

It assumes there is only one scanner connected to the computer that isn't some v4l camera. Modify it as necessary.

Much lighter than the 120 MiB of shit gnome's simple-scan would have added to my system.