Rather than carry a load of “dead tree” books with me on my travels, I have a collection of Microsoft Reader (.lit) ebooks on my laptop. The only problem is that there doesn’t seem to be any Linux software available to read them! Fortunately, the software exists to expand MS Reader files to plain HTML, which can then be converted to Postscript and on to PDF, which is most definitely handled by Linux.
The first program required is ConvertLit (slightly dubiously shortened to clit). The source is available, but since I’m running Ubuntu 8.04 on my laptop, I opted to install from the .deb files linked below.
sudo dpkg -i libtommath_0.37-1_i386.deb
sudo dpkg -i clit_1.8-1_i386.deb
Once ConvertLIT is installed, the process is as below.
clit my_book.lit html/
html2ps html/my_book.html > my_book.ps
ps2pdf my_book.ps my_book.pdf
Although simple, this can be time-consuming and repetitive, especially if you have a lot of files to convert! To deal with this I wrote a short shell script which runs through the process of converting a specified .lit file to PDF.
To use it, download the script and set the permissions to allow execution. I have a ~/bin directory in my $PATH for scripts and small bits of code that I’ve hacked together. It’s not required, but I find it pretty useful.
lit2pdf my_book.lit
My script only handles one file at a time, but something like this can be used to deal with entire directories.
#!/bin/sh
for file in *.lit ; do
lit2pdf "$file"
done
echo "Complete!\n"
Feel free to make changes, pass the script on, etc. It works well enough for my needs, but please let me know if you come up with an improvement. And remember, as the ConvertLIT usage screen says, “Please do not use this program to distribute illegal copies of ebooks. … that would make Baby Jesus sad.“
“find -iname *.lit -exec lit2pdf {} \;” is another method of working around that single file business in the initial script. This will also go into subdirectories, which I’m not sure will happen in the original suggested method.
Thanks a lot… It is working to the part where clit generates the htm
files from the .lit file. But html2ps gives out only one page, although the htm file is longer than one page… Do you have any idea why it is happening?
Hallo,
I’m sorry, the script seems works correctly, but I’m not able to find the .pdf
Where can I find it?
Thanks a lot!
The PDF file should be dumped into the same directory as the original .lit file, and have the same name (other than changing the file extension from .lit to .pdf).
Thank you very much for the answer. I imagined something similar, but it doesn’t work unfortunately. Now I am trying “calibre”, perhaps could be fine for my needs.
Thanks for the help however.
Ubuntu / Debian has all the requirements in the apt repos now.
$ sudo apt-get install convlit html2ps ghostscript
I’m only moderately sure about ghostscript being required, as I already had it installed on my system. But I think ghostscript is where ps2pdf comes from.
I also made a few changes to the script to allow for filenames containing spaces.
if [ ! -r "$*" ] ; then
echo “Usage: lit2pdf file.lit”
echo
exit 1
fi
# Change file extension
OF=`echo $* | sed ‘s/\.lit$/\.pdf/’`
TMPDIR=`mktemp -d`
# Expand file into temporary directory
clit “$*” $TMPDIR/temp/
# Convert HTML > PS > PDF
html2ps $TMPDIR/temp/*.htm | ps2pdf – “$OF”
# Clean up
rm -rf $TMPDIR
exit 0