Misc

Ebook

Batch convert lit to lrf :

find ./ -name "*.lit" |xargs -n1 -i lit2lrf --base-font-size=7 --author="blah" --author-sort="blah" --publisher="pub" {}

Batch convert chm to pdf :

 for fl in *.chm ;do echo \"$fl\" | xargs -i -n1  chm2pdf --portrait --strict --embedfonts --webpage --size a4 --left 3mm --right 10mm --top 3mm --bottom 3mm  '{}' '{}.pdf'; done

Remove spaces from file names (replace with "."):

 for fl in *.chm ;do echo \"$fl\" \"`echo $fl | sed s/\ /./g`\"| xargs -n2 mv; done

Convert PDF to LRF for non-embedded font pdfs

$ pdftotext -raw -nopgbrk book.pdf

$ GutenMark book.txt book.html

$ html2lrf book.html

or

$ pdftohtml -noframes -nomerge mybook.pdf
or
$ pdftohtml -noframes mybook.pdf

$ cat mybook.html |sed "s/<br>[a-z]//g" > mybook2.html

$ html2lrf --author="bob" --title="my book" --author-sort="bob" mybook2.html

or

$ pdftohtml -i -c -noframes -nomerge mybook.pdf (don't use -i if you have images you need)
or
$ html2lrf --disable-chapter-detection --base-font-size=20 --pdftohtml mybook.html

or

$ pdftohtml -i -c -noframes -nomerge mybook.pdf (don't use -i if you have images you need)
then
vi mybook.html
then
remove unnecessary line breaks :
:%s/<br>\([a-z]\)/ \1/g
remove dodgy div positionings :
:%s/<DIV style="position:absolute;top:[0-9]*;left:[0-9]*"><nobr>\(<span.*span>\)<.nobr><.DIV>/\1/g
then surplus divs around pages :
:%s/<DIV style="position:relative;width:[0-9]*;height:[0-9]*;">//g
then their corresponding end tags :
:%s/<\/DIV>//g

Remove extra lines in vi

:%s/\n\([^\w]\)/\1/g

Update libprs

sudo easy_install -U TTFQuery? libprs500 && libprs500_postinstall

Remove odd line breaks in vi

:%s/\([A-Za-z0-9\. \-\!]\)\(<BR>\)\([A-Za-z0-9\. \-\!]\)/\1\3/g