<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Pither.com: Multiple page scan to PDF</title>
    <link>http://www.pither.com/articles/2007/05/03/multiple-page-scan-to-pdf</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>by Simon Pither, freelance developer and systems administrator</description>
    <item>
      <title>Multiple page scan to PDF</title>
      <description>&lt;p&gt;Xsane does do this, but it's an awful lot of clicks, even between pages and that's after you've got to the right screen and before you eventually output the file.&lt;/p&gt;

&lt;p&gt;So here's a simple bash script to the rescue...&lt;/p&gt;

&lt;pre&gt;
#!/bin/bash

export DEVICE="device, use 'scanimage -L' to see list"

echo Pages: $1
echo Filename: $2

FILENAME_BASE="/tmp/$2"

for (( i = 1; $i &lt;= $1; i++ )); do
        echo Press ENTER to scan page $i
        read
        export FILENAME="$FILENAME_BASE.page.$i"
        scanimage -d "$DEVICE" &gt; "$FILENAME.pnm"
        pnmtops --width=8.27 --height=11.69 "$FILENAME.pnm" &gt; "$FILENAME.ps"
        FILELIST[$i - 1]="$FILENAME.ps"
done

gs -sDEVICE=pswrite "-sOutputFile=$FILENAME_BASE.ps" -dNOPAUSE -dBATCH "${FILELIST[@]}"
ps2pdf "$FILENAME_BASE.ps" "$2.pdf"

for f in "${FILELIST[@]}"; do
        rm "$f"
done
rm "$FILENAME_BASE.ps"

&lt;/pre&gt;

&lt;p&gt;Just give it the number of pages to scan and the output file name to use (without .pdf).  It will prompt you for each page to be ready (I don't have a document feeder), scan them, combine them and convert it all to a PDF.&lt;/p&gt;

&lt;p&gt;It does have a number of dependency utilities, but I already had them all installed and this was only a quick hack so I've not made a list.&lt;/p&gt;</description>
      <pubDate>Thu, 03 May 2007 12:53:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:56b2ec07-35ea-4ab4-b432-7fd5e9a32bb3</guid>
      <author>Simon</author>
      <link>http://www.pither.com/articles/2007/05/03/multiple-page-scan-to-pdf</link>
      <category>documents</category>
      <category>bash</category>
      <category>scan</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
