View Single Post
Old 11-07-2010, 08:55 PM   #4
scotsman
Enthusiast
scotsman doesn't litterscotsman doesn't litter
 
Posts: 32
Karma: 106
Join Date: Mar 2009
Device: irex DR1000S
updated version, to also work with firmware 2.0

Hi all,

I got a new version of the scribble viewer script. It works with firmware 2.0 if you use my converter script on https://www.mobileread.com/forums/sho...61#post1204261
It copies the metadata to a temporary location before converting it back to version 1.x, so your original data does not get messed up.

#!/bin/bash
#view DR pdf files by first merging the file

#todo: rewrite file names with spaces into proper linux filenames with space indicators. Otherwise trouble with some pdfs


tempdir=/tmp/ism
suffix="_ismtempfile"
options="-all -color blue -opacity 1 -suffix $suffix"
pdfviewer="evince"

if [ ! -e $tempdir ];then mkdir $tempdir; fi

#possibly add -overwrite
#echo $1 > /tmp/DRpdfview.log
path=`dirname $1`
file=`basename $1`
mergedfile="${file/.pdf/$suffix.pdf}"
if [ "$path" = "$1" ] #to avoid problems when no path is given
then
path=""
fi

if [ -e $path"/metadata.db" ] #needed because otherwise ism gives a fatal error
then
cp $path"/metadata.db" $tempdir
cp $1 $tempdir
DRmetadata_converter.sh $tempdir"/metadata.db"
error=`ism $options $tempdir"/"$file`
rm $tempdir"/"$file
rm $tempdir"/metadata.db"

else
error="no metadata"
fi
echo $error
#error=${error%$1*}
error=${error%% *} #cuts the error string to the first word (a bit dirty, but should be no problem unless ism gives more than one error message, which are then not distinguished)

if [ -z $error ]
then
$pdfviewer $tempdir"/"$mergedfile
rm $tempdir"/"$mergedfile
else
$pdfviewer $1
fi

#this command renames all files with Merged.pdf into _an.pdf
#find ./ -name *Merged.pdf -exec rename "s/Merged/an/g" {} \;
scotsman is offline   Reply With Quote