Hi,
On Fri, 27 May 2005, Tim Oliver Wagner wrote:
ich habe häufig PDFs durchzulesen und möchte mir Kommentare und
Textmarkierungen im PDF hinzufügen. Damit ich beim erneuten Anschauen nicht
wieder alles lesen muss und herauszubekommen wo die wichtigen Informationen
stehen.
Funktioniert das unter Linux? Wenn ja mit welchem Programm denn?
PDF ist ein read only format (auch wenn manche inzwischen versuchen
etwas anderes daraus zu machen)
für ebooks habe ich mir ein kleines script geschrieben, damit ich
die entsprechende seite schnell wieder finde.
Benötigt werden awk, xpdf, md5sum und was ich noch vergessen
hab.
<script>
#!/bin/sh
# Skript to read ebooks
# It is released under the GPL
# Copyright d_lord@gmx.de
#
# Some things to configure
#
# path to xpdf binary
XPDF="/usr/bin/xpdf"
# xpdf options
OPT=" -q -g 1012x716+0+0 -z width"
# awk binary
AWK="/usr/bin/awk"
# dir to store the last read pages in
EBOOKDIR="$HOME/.ebook"
# usefull for tmpfs with laptop to save batterypower
# the script will copy all needed files to this dir to allow
# the harddisc to sleep If you don't use tmpfs leave this blank.
# Temporary files won't be deleted.
TMPDIR="/tmp"
#
# After here things should remain unchanged
#
# Current Version
VERSION="0.1"
# Debug
#set -vx
function init_check ()
{
# Check if there is a xpdf binary (don't want to use which)
if ! test -x "${XPDF}"
then
echo "${XPDF} not found"
exit -1
fi
# Check if AWK is present
if ! test -x "${AWK}"
then
echo "${AWK} not found"
exit -1
fi
# Only one argument allowed at the moment
if test "$ARGC" -ne "1"
then
echo "usage: ${PROG} "
exit -1
fi
# Check if we really got an PDF dokument as first argument
PDF=`file "${ARGV}" | grep ": PDF document, version"`
if test "x${PDF}" = "x"
then
echo "Please give me a pdf document"
exit -1
fi
# Check if the Bookmark directory exists
if ! test -d "${EBOOKDIR}"
then
if ! mkdir -p "${EBOOKDIR}"
then
echo "Failed to create bookmark directory ${EBOOKDIR}"
exit -1
fi
fi
}
function gen_tempfiles ()
{
# check for tmpdir
if ! test "x${TMPDIR}" = "x"
then
# does the directory exist?
if ! test -d "${TMPDIR}"
then
echo "No such TMPDIR (${TMPDIR})"
exit -1
else
# generate the temporary file
umask 077
EBOOK=`mktemp -p "${TMPDIR}" ebook.cache.XXXXXXXXXX`
cp "${ARGV}" "${EBOOK}"
fi
else
EBOOK="${ARGV}"
fi
}
function get_last_page ()
{
# get last Page or set LP to first page
BOOKMARK="${EBOOKDIR}/`md5sum ${ARGV} | ${AWK} '{print $1}'`"
# check if file exists and init some vars
ls -1 ${BOOKMARK}_* > /dev/null 2>&1
if test $? -ne 0
then
BMFILE="${BOOKMARK}_${PDFFILE}"
LP="1"
else
BMFILE="`ls -1 ${BOOKMARK}_*`"
LP=`tail -n 1 "${BMFILE}"`
# should not be reached. Only if file is empty
if test "x${LP}" = "x"
then
BMFILE="${BOOKMARK}_${PDFFILE}"
LP="1"
fi
fi
}
function greeting ()
{
# greeting displayed at the startup
cat << EOF
This is my ebook reader script version ${VERSION}.
It's released under GPL. Enjoy.
Copyright Daniel Lord, comments, feedback to d_lord@gmx.de
EOF
}
function exec_xpdf ()
{
# start with -cmd to get the last page
LP=`${XPDF} ${OPT} -cmd "${EBOOK}" "$LP" |\
${AWK} '/page/ {printf("%s\n",$3)}' | tail -n 1`
}
function write_lp ()
{
# Provide some info to the user and write the new bookmark
echo "Page ${LP} will be saved as bookmark in ${BMFILE}"
echo ${LP} > "${BMFILE}"
}
ARGC=$#
PROG="${0}"
ARGV="${1}"
PDFFILE="`basename "${ARGV}"`"
greeting
init_check
gen_tempfiles
get_last_page
exec_xpdf
write_lp
</script>
Greetings Daniel
--
Die Welt wird nicht bedroht von den Menschen, die böse sind,
sondern von denen, die wegschauen.