Re: (solved)Re: how to scan a book
On Tue, 2011-01-04 at 16:59 -0700, Bob Proulx wrote:
> Long Wind wrote:
> > Paul Cartwright wrote:
> > > if you take JPG pictures, you can open up OpenOffice Writer, import the
> > > JPEGs into a DOC & SAVE-AS PDF..
> >
> > Thank Paul Cartwright !
> > I'll try Writer later on.
>
> That is a good suggestion. But it sounds tedious to me.
>
> ImageMagick can convert images to pdf files on the command line.
>
> $ convert file1.jpg file1.pdf
>
> And pdftk can concatenate them.
>
> $ pdftk file*.pdf cat output combined.pdf
>
> You can install them with:
>
> $ sudo apt-get install imagemagick pdftk
>
> Bob
Seems like a week for PDF tricks! Just as we found the tip about
reducing PDF file size helpful and converted it to a KDE Konqueror
servicemenu, so we did for this suggestion to produce a PDF bind service
menu. In case it may be of use to anyone, here is the script:
#!/bin/bash
TITLE="PDF Binder"
FILES=""
DIR="${1}"
NEWFILE=""
OFILE=""
OK=true
kdialog --title "${TITLE}" --yesno "You must select your files one at a
time.\nThat is the only way I will know in which order to bind
them.\nWhen you have finished selecting files, click cancel.\nI will
then ask you where to save the bound file.\nShall I continue?"
if [ $? -ne 0 ];then
exit 4
fi
while true
do
NEWFILE="$(kdialog --title "Select PDF File to Bind" --getopenfilename
"${DIR}")"
if [ $? -ne 0 ];then
break
fi
if [ ! -f "${NEWFILE}" ];then
kdialog --title "${TITLE}" --error "The \"${NEWFILE}\" file does not
exist"
continue
fi
FILES="${FILES} \"${NEWFILE}\""
DIR="${NEWFILE%/*}"
done
if [ -z "${FILES}" ];then
kdialog --title "${TITLE}" --msgbox "No files were selected"
exit 5
fi
while ${OK}
do
OFILE="$(kdialog --title "Enter Bound File Name" --getsavefilename
"${DIR}")"
if [ $? -eq 0 ];then
EXT="${OFILE: -4:4}"
if [ "${EXT}" != ".pdf" -a "${EXT}" != ".PDF" ];then
OFILE="${OFILE}.pdf"
fi
if [ -f "${OFILE}" ];then
kdialog --title "${TITLE}" --warningyesno "The file
${OFILE} already exists.\nShall I overwrite it?"
if [ $? -ne 0 ];then
continue
fi
fi
OK=false
else
kdialog --title "${TITLE}" --yesno "Do you really want to cancel the
bind?"
if [ $? -eq 0 ];then
exit 6
fi
fi
done
FNAME="${OFILE##*/}"
DNAME="${OFILE%/*}"
kdialog --title "${TITLE}" --msgbox "PDF binding can take several
minutes.\nYou will be notified via popup when the process is
complete.\nThank you." &
eval pdftk ${FILES} cat output \"${HOME}/tmp/${FNAME}\"
ret=$?
if [ $ret -eq 0 ];then
mv "${HOME}/tmp/${FNAME}" "${OFILE}"
ret=$?
fi
if [ $ret -ne 0 ];then
rm -f "${HOME}/tmp/${FNAME}"
kdialog --title "${TITLE}" --error "PDF binding of ${OFILE}
failed."
exit 5
fi
kdialog --title "${TITLE}" --msgbox "PDF Binding Completed for:\n
${OFILE}"
And here is the service menu definition in
<KDEDIR>/share/apps/konqueror/servicemenus/39748-bindpdf.desktop:
[Desktop Action Bind_PDF]
Exec=/data/.Common/apps/PDFHandlers/bindpdf "%F"
Icon=kpdf
Name=Bind PDF file(s)
[Desktop Entry]
Actions=Bind_PDF
Encoding=UTF-8
ServiceTypes=application/pdf,application/vnd.adobe.pdf
Reply to: