Posts Tagged ‘PDF’

Kindle Touch landscape mode – Ubuntu / Linux fix (my solution…)

December 5, 2011

I got my Kindle Touch Wi-Fi with special offers last week. More info on this nice device at the Amazon Kindle Touch page, the Kindle Wikipedia article page, and of course Google searches will do you lots of good.

Granted I’m busy so I’ve not been able to maximize its use yet but I’ve been able to play with it and organize my books and personal documents already. Overall I like the look and feel and functionality of the Kindle Touch (or KT) and I believe you can search reviews with Google, including this good Kindle Touch review by CNET. For reading novels in the native formats accepted by Kindle (e.g. .mobi, .azw files) the pinch-and-zoom as well as the swipe (or just tap) to go to the next/previous page, among other features of KT, are great.

As a researcher though I have lots of PDFs to read, many of which have text formatted in mathematical notation (such as those made using LaTeX). Of course KT can handle PDFs, and even though you could pinch-and-zoom as well as swipe to pan through a page or through pages, reading a PDF  file this way can be really cumbersome especially since the default orientation of viewing in KT is portrait mode. It would be nice if we can rotate the KT to landscape orientation to better read PDF files. However, according to an official statement from a Kindle Customer Support representative, landscape mode is not available on KT. Bummer. I immediately emailed Amazon at (all of you should! 🙂 ) asking for future software/firmware update to automatically change orientation in KT, and when might this be.

Right now, a sort of “hack” is possible to allow Ubuntu (and other GNU/Linux distros) users like myself to read our PDF books and files in landscape mode in the KT. An answer is to use the pdftk commandline tool which I made a post about some time ago. You can also refer to the man page of your GNU/Linux distribution after installing pdftk. In Ubuntu, a simple and quick apt-get or Synaptic installation should  do the installation job for you (check my post about pdftk above, or search this blog). The “hack” goes like so:

Say you have a PDF file named mydoc.pdf. To rotate the entire PDF file (assuming it is in portrait orientation by default) 90 degrees counterclockwise (so now the mydoc.pdf is now in landscape orientation) fire up a terminal and type:

$ pdftk mydoc.pdf cat 1-endW output tmp.pdf

Where tmp.pdf is the desired output filename of the re-oriented (now in landscape) version of mydoc.pdf. Now you can copy or email the file tmp.pdf to your KT and read your PDF file in landscape mode. 🙂 I’ve yet to check if pdftk works in Mac OS (I won’t be surprised if it does) though I believe this pseudo-hack might turn out to be more “graphical” or point-and-click in nature than my commandline solution above. 🙂 A user from the Amazon KT support page above mentioned using a professional version of Adobe reader to graphically do this, perhaps in Windows and in Mac OS as well. I’d appreciate if somebody would post a link on how to do this graphically in Ubuntu (GNU/Linux), Mac OS, and even in….Windows… 😉 🙂

Happy hacking and Kindling. 🙂

Pretty Practicable PDF Tricks In Linux

March 23, 2009

I still don’t have quite a lot of time to write a more or less decent technology or philosophy or science/math related post, but I just want to put this on my blog for the sake of reference  again (as most, if not all, of my blog entries).

My Dilemma

I have a copy of a pdf file from which I want to share some parts only to my lab exercise partner (for reasons I can’t exactly divulge in the public Internet). So I Google around how to manipulate, specifically to  pluck/extract specific pages from a pdf file, and still output the extracted files as pdf file/s themselves. Then I found pdftk. Fantastic tool. Really.

Why Is It Fantastic?

Here are a few reasons why:

For such a small (more or less) package (3408kB in my Ubuntu 8.10 installation) you can:

Pdftk can join and split PDFs; pull single pages from a file; encrypt and decrypt PDF files; add, update, and export a PDF’s metadata; export bookmarks to a text file; add or remove attachments to a PDF; fix a damaged PDF; and fill out PDF forms. In short, there’s very little pdftk can’t do when it comes to working with PDFs.


Developer Sid Steward describes pdftk as the PDF equivalent of an “electronic staple remover, hole punch, binder, secret decoder ring, and X-ray glasses.”  Pdftk can join and split PDFs; pull single pages from a file; encrypt and decrypt PDF files; add, update, and export a PDF’s metadata; export bookmarks to a text file; add or remove attachments to a PDF; fix a damaged PDF; and fill out PDF forms.

Swiss army knife of PDF files anyone? And thankfully, it’s free and open source. The above quotes are from, and a lot of us know that once something gets posted on, it’s more or less worthwhile to learn, more so to read at the very least. pdftk is a command line tool (sorry, but check out my further references below).

And installing it is just simply

sudo apt-get install pdftk

in my Ubuntu 8.04 and 8.10 installations. Again, quoting from, here are some very useful (at least to me) things you can do with pdftk. Of course, with a bit of knowledge in scripting or programming (bash, php, python etc) you can work wonders with this tool:

Joining files

Pdftk’s ability to join two or more PDF files is on par with such specialized applications as pdfmeld and joinPDF (discussed in this article). The command syntax is simple:

pdftk file1.pdf file2.pdf cat output newFile.pdf

cat is short for concatenate — that is, link together, for those of us who speak plain English — and output tells pdftk to write the combined PDFs to a new file.

Pdftk doesn’t retain bookmarks, but it does keep hyperlinks to both destinations within the PDF and to external files or Web sites. Where some other applications point to the wrong destinations for hyperlinks, the links in PDFs combined using pdftk managed to hit each link target perfectly.

Splitting files

Splitting PDF files with pdftk was an interesting experience. The burst option breaks a PDF into multiple files — one file for each page:

pdftk user_guide.pdf burst

I don’t see the use of doing that, and with larger documents you wind up with a lot of files with names corresponding to their page numbers, like pg_0001 and pg_0013 — not very intuitive.

On the other hand, I found pdftk’s ability to remove specific pages from a PDF file to be useful. For example, to remove pages 10 to 25 from a PDF file, you’d type the following command:

pdftk myDocument.pdf cat 1-9 26-end output removedPages.pdf

Updated Man page

For all the geeks and geekettes out there (no this sub heading is not sexist), here’s an updated man page from my Ubuntu 8.10 server installation:

PDFTK(1)                                                                                                                          PDFTK(1)

pdftk – A handy tool for manipulating PDF

pdftk <input PDF files | – | PROMPT>
[input_pw <input PDF owner passwords | PROMPT>]
[<operation> <operation arguments>]
[output <output filename | – | PROMPT>]
[encrypt_40bit | encrypt_128bit]
[allow <permissions>]
[owner_pw <owner password | PROMPT>]
[user_pw <user password | PROMPT>]
[flatten] [compress | uncompress]
[keep_first_id | keep_final_id] [drop_xfa]
[verbose] [dont_ask | do_ask]
<operation> may be empty, or:
[cat | attach_files | unpack_files | burst |
fill_form | background | stamp | generate_fdf
dump_data | dump_data_fields | update_info]

For Complete Help: pdftk –help

If PDF is electronic paper, then pdftk is an electronic staple-remover, hole-punch, binder, secret-decoder-ring, and X-Ray-glasses.
Pdftk is a simple tool for doing everyday things with PDF documents.  Use it to:

* Merge PDF Documents
* Split PDF Pages into a New Document
* Rotate PDF Documents or Pages
* Decrypt Input as Necessary (Password Required)
* Encrypt Output as Desired
* Fill PDF Forms with X/FDF Data and/or Flatten Forms
* Generate FDF Data Stencil from PDF Forms
* Apply a Background Watermark or a Foreground Stamp
* Report PDF Metrics such as Metadata and Bookmarks
* Update PDF Metadata
* Attach Files to PDF Pages or the PDF Document
* Unpack PDF Attachments
* Burst a PDF Document into Single Pages
* Uncompress and Re-Compress Page Streams
* Repair Corrupted PDF (Where Possible)

A summary of options is included below.

–help, -h
Show summary of options.

<input PDF files | – | PROMPT>
A list of the input PDF files. If you plan to combine these PDFs (without using handles) then list files in  the  order  you
want  them  combined.  Use – to pass a single PDF into pdftk via stdin.  Input files can be associated with handles, where a
handle is a single, upper-case letter:

<input PDF handle>=<input PDF filename>

Handles are often omitted.  They are useful when specifying PDF passwords or page ranges, later.

For example: A=input1.pdf B=input2.pdf

[input_pw <input PDF owner passwords | PROMPT>]
Input PDF owner passwords, if necessary, are associated with files by using their handles:

<input PDF handle>=<input PDF file owner password>

If handles are not given, then passwords are associated with input files by order.

Most pdftk features require that encrypted input PDF are accompanied by the ~owner~ password. If the input PDF has no  owner
password,  then  the  user  password  must be given, instead.  If the input PDF has no passwords, then no password should be

When running in do_ask mode, pdftk will prompt you for a password if the supplied password is incorrect or none was given.

[<operation> <operation arguments>]
If this optional argument is omitted, then pdftk runs in ’filter’ mode.  Filter mode takes only one PDF input and creates  a
new PDF after applying all of the output options, like encryption and compression.

Available operations are: cat, attach_files, unpack_files, burst, fill_form, background, stamp, dump_data, dump_data_fields,
generate_fdf, update_info. Some operations takes additional arguments, described below.

cat [<page ranges>]
Catenates pages from input PDFs to create a new PDF.  Page order in the new PDF is specified by the order  of  the  given
page ranges.  Page ranges are described like this:

<input PDF handle>[<begin page number>[-<end page number>[<qualifier>]]][<page rotation>]

Where  the  handle  identifies one of the input PDF files, and the beginning and ending page numbers are one-based refer‐
ences to pages in the PDF file, and the qualifier can be even or odd, and the page rotation can be N, S, E, W, L,  R,  or

If the handle is omitted from the page range, then the pages are taken from the first input PDF.

The  even  qualifier  causes  pdftk  to  use only the even-numbered PDF pages, so 1-6even yields pages 2, 4 and 6 in that
order.  6-1even yields pages 6, 4 and 2 in that order.

The odd qualifier works similarly to the even.

The page rotation setting can cause pdftk to rotate pages and documents.  Each option sets the page rotation  as  follows
(in  degrees):  N:  0,  E: 90, S: 180, W: 270, L: -90, R: +90, D: +180. L, R, and D make relative adjustments to a page’s

If no arguments are passed to cat, then pdftk combines all input PDFs in the order they were given to create the  output.

* <end page number> may be less than <begin page number>.
* The keyword end may be used to reference the final page of a document instead of a page number.
* Reference a single page by omitting the ending page number.
* The handle may be used alone to represent the entire PDF document, e.g., B1-end is the same as B.

Page Range Examples w/o Handles:
1-endE – rotate entire document 90 degrees
5 11 20
5-25oddW – take odd pages in range, rotate 90 degrees

Page Range Examples Using Handles:
Say A=in1.pdf B=in2.pdf, then:
A1-21 Beven A72
AW – rotate entire document 90 degrees
A2-30evenL – take the even pages from the range, remove 90 degrees from each page’s rotation
AevenW AoddE

attach_files <attachment filenames | PROMPT> [to_page <page number | PROMPT>]
Packs  arbitrary  files  into  a  PDF  using PDF’s file attachment features. More than one attachment may be listed after
attach_files. Attachments are added at the document level unless the optional to_page option is given, in which case  the
files are attached to the given page number (the first page is 1, the final page is end). For example:

pdftk in.pdf attach_files table1.html table2.html to_page 6 output out.pdf

Copies  all  of  the attachments from the input PDF into the current folder or to an output directory given after output.
For example:

pdftk report.pdf unpack_files output ~/atts/

or, interactively:

pdftk report.pdf unpack_files output PROMPT

burst  Splits a single, input PDF document into individual pages. Also creates a report named doc_data.txt which is the same  as
the  output  from dump_data.  If the output section is omitted, then PDF pages are named: pg_%04d.pdf, e.g.: pg_0001.pdf,
pg_0002.pdf, etc.  To name these pages yourself, supply a printf-styled format string via the output section.  For  exam‐
ple,  if  you  want  pages  named: page_01.pdf, page_02.pdf, etc., pass output page_%02d.pdf to pdftk.  Encryption can be
applied to the output by appending output options such as owner_pw, e.g.:

pdftk in.pdf burst owner_pw foopass

fill_form <FDF data filename | XFDF data filename | – | PROMPT>
Fills the single input PDF’s form fields with the data from an FDF file, XFDF file or  stdin.  Enter  the  data  filename
after fill_form, or use – to pass the data via stdin, like so:

pdftk form.pdf fill_form data.fdf output form.filled.pdf

After  filling  a  form, the form fields remain interactive unless you also use the flatten output option. flatten merges
the form fields with the PDF pages. You can use flatten alone, too, but only on a single PDF:

pdftk form.pdf fill_form data.fdf output out.pdf flatten


pdftk form.filled.pdf output out.pdf flatten

If the input FDF file includes Rich Text formatted data in addition to plain text, then the Rich Text data is packed into
the form fields as well as the plain text.  Pdftk also sets a flag that cues Acrobat/Reader to generate new field appear‐
ances based on the Rich Text data.  That way, when the user opens the PDF, the viewer will create the Rich Text fields on
the  spot.   If the user’s PDF viewer does not support Rich Text, then the user will see the plain text data instead.  If
you flatten this form before Acrobat has a chance to create (and save) new field appearances, then the plain  text  field
data is what you’ll see.

background <background PDF filename | – | PROMPT>
Applies  a  PDF  watermark  to the background of a single input PDF.  Pass the background PDF’s filename after background
like so:

pdftk in.pdf background back.pdf output out.pdf

Pdftk uses only the first page from the background PDF and applies it to every page of  the  input  PDF.   This  page  is
scaled and rotated as needed to fit the input page.  You can use – to pass a background PDF into pdftk via stdin.

If  the input PDF does not have a transparent background (such as a PDF created from page scans) then the resulting back‐
ground won’t be visible — use the stamp feature instead.

stamp <stamp PDF filename | – | PROMPT>
This behaves just like the background feature except it overlays the stamp PDF page on top of the  input  PDF  document’s
pages.  This works best if the stamp PDF page has a transparent background.

Reads  a  single, input PDF file and reports various statistics, metadata, bookmarks (a/k/a outlines), and page labels to
the given output filename or (if no output is given) to stdout.  Does not create a new PDF.

Reads a single, input PDF file and reports form field statistics to the given output filename or (if no output is  given)
to stdout.  Does not create a new PDF.

Reads  a single, input PDF file and generates a FDF file suitable for fill_form out of it to the given output filename or
(if no output is given) to stdout.  Does not create a new PDF.

update_info <info data filename | – | PROMPT>
Changes the metadata stored in a single PDF’s Info dictionary to match the input data file. The input data file uses  the
same  syntax  as  the  output from dump_data. This does not change the metadata stored in the PDF’s XMP stream, if it has
one. For example:

pdftk in.pdf update_info output out.pdf

[output <output filename | – | PROMPT>]
The output PDF filename may not be set to the name of an input filename.  Use  –  to  output  to  stdout.   When  using  the
dump_data  operation,  use output to set the name of the output data file. When using the unpack_files operation, use output
to set the name of an output directory.  When using the burst operation, you can use output to  control  the  resulting  PDF
page filenames (described above).

[encrypt_40bit | encrypt_128bit]
If an output PDF user or owner password is given, output PDF encryption strength defaults to 128 bits.  This can be overrid‐
den by specifying encrypt_40bit.

[allow <permissions>]
Permissions are applied to the output PDF only if an encryption strength is specified or an owner or user password is given.
If permissions are not specified, they default to ’none,’ which means all of the following features are disabled.

The permissions section may include one or more of the following features:

Top Quality Printing

Lower Quality Printing

Also allows Assembly


Also allows ScreenReaders


Also allows FillIn


Allows the user to perform all of the above, and top quality printing.

[owner_pw <owner password | PROMPT>]

[user_pw <user password | PROMPT>]
If  an  encryption  strength  is  given but no passwords are supplied, then the owner and user passwords remain empty, which
means that the resulting PDF may be opened and its security parameters altered by anybody.

[compress | uncompress]
These are only useful when you want to edit PDF code in a text editor like vim or emacs.  Remove PDF page stream compression
by applying the uncompress filter. Use the compress filter to restore compression.

Use  this  option  to merge an input PDF’s interactive form fields (and their data) with the PDF’s pages. Only one input PDF
may be given. Sometimes used with the fill_form operation.

[keep_first_id | keep_final_id]
When combining pages from multiple PDFs, use one of these options to copy the document ID from either  the  first  or  final
input  document  into the new output PDF. Otherwise pdftk creates a new document ID for the output PDF. When no operation is
given, pdftk always uses the ID from the (single) input PDF.

If your input PDF is a form created using Acrobat 7 or Adobe Designer, then it probably has XFA data.  Filling such  a  form
using  pdftk  yields  a PDF with data that fails to display in Acrobat 7 (and 6?).  The workaround solution is to remove the
form’s XFA data, either before you fill the form using pdftk or at the time you fill the  form.  Using  this  option  causes
pdftk to omit the XFA data from the output PDF form.

This  option  is  only  useful  when  running pdftk on a single input PDF.  When assembling a PDF from multiple inputs using
pdftk, any XFA data in the input is automatically omitted.

By default, pdftk runs quietly. Append verbose to the end and it will speak up.

[dont_ask | do_ask]
Depending on the compile-time settings (see ASK_ABOUT_WARNINGS), pdftk might prompt you for further input when it encounters
a  problem, such as a bad password. Override this default behavior by adding dont_ask (so pdftk won’t ask you what to do) or
do_ask (so pdftk will ask you what to do).

When running in dont_ask mode, pdftk will over-write files with its output without notice.

Decrypt a PDF
pdftk secured.pdf input_pw foopass output unsecured.pdf

Encrypt a PDF using 128-bit strength (the default), withhold all permissions (the default)
pdftk 1.pdf output 1.128.pdf owner_pw foopass

Same as above, except password ’baz’ must also be used to open output PDF
pdftk 1.pdf output 1.128.pdf owner_pw foo user_pw baz

Same as above, except printing is allowed (once the PDF is open)
pdftk 1.pdf output 1.128.pdf owner_pw foo user_pw baz allow printing

Join in1.pdf and in2.pdf into a new PDF, out1.pdf
pdftk in1.pdf in2.pdf cat output out1.pdf
or (using handles):
pdftk A=in1.pdf B=in2.pdf cat A B output out1.pdf
or (using wildcards):
pdftk *.pdf cat output combined.pdf

Remove ’page 13’ from in1.pdf to create out1.pdf
pdftk in.pdf cat 1-12 14-end output out1.pdf
pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf

Apply 40-bit encryption to output, revoking all permissions (the default). Set the owner PW to ’foopass’.
pdftk 1.pdf 2.pdf cat output 3.pdf encrypt_40bit owner_pw foopass

Join two files, one of which requires the password ’foopass’. The output is not encrypted.
pdftk A=secured.pdf 2.pdf input_pw A=foopass cat output 3.pdf

Uncompress PDF page streams for editing the PDF in a text editor (e.g., vim, emacs)
pdftk doc.pdf output doc.unc.pdf uncompress

Repair a PDF’s corrupted XREF table and stream lengths, if possible
pdftk broken.pdf output fixed.pdf

Burst a single PDF document into pages and dump its data to doc_data.txt
pdftk in.pdf burst

Burst a single PDF document into encrypted pages. Allow low-quality printing
pdftk in.pdf burst owner_pw foopass allow DegradedPrinting

Write a report on PDF document metadata and bookmarks to report.txt
pdftk in.pdf dump_data output report.txt

Rotate the first PDF page to 90 degrees clockwise
pdftk in.pdf cat 1E 2-end output out.pdf

Rotate an entire PDF document to 180 degrees
pdftk in.pdf cat 1-endS output out.pdf

pdftk uses a slightly modified iText Java library ( to read and write  PDF.  The  author  compiled
this Java library using GCJ ( so it could be linked with a front end written in C++.

The pdftk home page is

Sid Steward ( maintains pdftk.

September 18, 2006                                                    PDFTK(1)

Comments, questions, and suggestions are always welcome as long as they’re calm and ruly 🙂

Further References

>> reference article

>>Main site for pdftk (including manual/documentation), a bit dated though

>> GUI for pdftk

Reading e-books in Linux

May 6, 2008

This post is about how one can read and enjoy their e-books in Linux, covering some of the more popular e-book formats and the software used to view them.

I love books. I love reading them whether they be in tangible (physical bound books) or intangible (electronic) form. Hence my increased infatuation when I discovered the joys of e-books years ago. I don’t have a portable device whose sole purpose is to let me read and view my e-books (since I refuse to carry devices which are built only for a single purpose), but I do have gadgets that do a lot of things, reading e-books included. However, I usually do my e-book reading in my PC/Linux box.

Popular e-book formats

Among the numerous e-book formats, the most prolific (in my opinion) format is PDF. There are many software and applications in Linux which can open and view PDF files, such as KPDF (the one that I use most of the time because it can be used as an embedded pdf viewer in Konqueror), XPDF, and Adobe Reader, among others. Acquiring those into your Linux distribution shouldn’t be a problem. Usually I prefer my e-books to be of PDF type since PDF stores data in vector format and at present, a lot of PDF files are coming out with OCR, which is great but which is not to say that it doesn’t have its cons, but for most reading purposes PDF files come out on top.

Another format is CHM, whose file types can be viewed in Linux using programs such as kchmviewer, and gnochm. I prefer kchmviewer at the moment, since it has a lot of useful features.

Another format which is used more recently is the DJVU format. Linux users can rest assured that DJVU file viewers are available for them, such as Djview, which can also be embedded in Konqueror. There are also browser plug-ins for opening DJVU files.

There are numerous more other e-book viewers such as fbreader which can open fb2 e-book format, Palmdoc, zTxt, TCR, RTF, OEB, OpenReader format and some other formats. One of the new book readers I’m really looking forward to is Okular, the new KDE4 PDF viewer, and also boasts of being able to open also CHM, and DJVU files among others. No need for a lot of separate book viewers.

Lastly, I’ll mention about the LIT book types, which is a proprietary file type by Microsoft. I’m not a big fan of Microsoft but some of the books I get are in .lit format. In order to view those files (or convert them into files already viewable) in Linux, small things need to be done.

Handling LIT files in Linux

A software, Calibre, can be used to open and view HTML, text, RTF, and LRF files, as well as convert LIT files to the former formats, if properly configured. Calibre is a reverse-engineered alternative reader for Sony’s e-reader. Calibre creates a library for your e-books, stored in a self-contained sqlite database format. If you’re an Ubuntu user, you simply do the following to install Calibre in your machine:

Enter the following command and make sure it returns at least a version of 2.5.1

python --version

then afterwards enter these

sudo apt-get install  python-setuptools python-imaging  libqt4-core libqt4-gui \
                      python-qt4 fonttools python-mechanize imagemagick \
                      xdg-utils python-dbus  python-lxml \
                      librsvg2-bin python-genshi help2man
sudo easy_install -U TTFQuery calibre
sudo calibre_postinstall

afterwards you install the tool convert-lit or clit by first installing the libtommath package

sudo dpkg -i libtommath_0.37-1_i386.deb

then finally install clit

sudo dpkg -i clit_1.8-1_i386.deb

Calibre can also be easily installed on other Linux distros such as Gentoo, Debian, and Fedora.

The Convert-lit or clit tool

Convert-lit or clit is the tool that is used by Calibre and all the succeeding software I’ll be mentioning here (in fact, it is the only tool for handling .lit files in Linux at present). Convert-lit or clit has 3 capabilities: The first of the clit command explodes (decompiles) the .lit ebook input file into its constituent HTML file and images which it places in the in an ouput directory. The output directory must already exist. To decompile a .lit e-book:

              mkdir my-ebook; clit my-ebook.lit my-ebook

The second form downconverts the .lit e-book file to a “Sealed” or DRM1 format file. This is useful for reading on handheld devices. To downconvert a .lit e-book:

clit my-ebook-drm5.lit my-ebook-drm1.lit

The third form inscribes the .lit ebook with the given label. To label a .lit e-book:

clit my-ebook-drm5.lit my-ebook-drm1.lit "Title of My-Ebook"

Now you can read your LIT e-books using any application that can open HTML files. If you have a large number of LIT e-books you want to convert, a shell script (which I modified a bit) from a fellow Ubuntu forums user, BobCFC, can be used:

# process every .lit file in the current directory
# use clit to explode each file into directory of same name minus .lit extention
# (optional pass -z argument to create gzip files and remove new directories)
# 2007 RBH

if [ $1 == '-z' ]
        for FILENAME in *.lit
                clit "$FILENAME" "${FILENAME%%.lit}"/
                tar czf "${FILENAME%%.lit}".tar.gz "${FILENAME%%.lit}"
                rm -rf "${FILENAME%%.lit}"
        for FILENAME in *.lit
                clit "$FILENAME" "${FILENAME%%.lit}"/

Save the shell script above in any file name you want, they make it executable by issuing chmod +x filename . The script will extract all the .lit files in the current directory into folders of the same name. Use the -z flag to create compressed gzip files instead.

Compiling clit

For those of you who’ll be needing to compile clit since their distros don’t have clit packages:

– you’ll need the “build-essential” package

– download the clit source file here:
– download the libtommath source code here (make sure that you get the 0.30 version since as of clit version 1.8, clit uses version 0.30 of libtommath and not the latest 0.39 version) :
– Extract the downloaded clit and libtomath files in same directory e.g. enter the commands:

unzip ; tar jxvf ltm-0.30.tar.bz2

cd to the libtommath directory ; issue the command make
cd to clit<version_number>/lib directory; issue again make
cd to clit source directory, clit<version_number>, mine was clit18/

– issue again make – this should use the libtommath built above. You can check to see if you’ve successfully compiled an executable binary file which you can run as clit (assuming there were no error messages after all the make commands you entered) by issuing the command:

file clit

which returns the following in my 64 bit AMD processor:

clit: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), not stripped

or the following in my 32 bit AMD processor:

clit: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), not stripped

Now you can use the clit commands shown above by copying the compiled clit binary file to your bin directory

sudo cp -v clit /usr/bin/

clit in Firefox

If you use Firefox or any of its derivatives, there is an add-on, OpenBerg, which lets you view a number of book formats including comic book archives (.cbr, .cbz) and even .lit files, among others. However, you must have rar, zip, and lit viewer/handler programs already installed in your system/Linux box. The clit setup I mentioned above is just right for allowing OpenBerg to let you view your .lit files. What the add-on actually does is it explodes/converts your .lit books (1st command above) into a browser readable HTML fiile. You have to point OpenBerg to the directory where the clit executable binary file is located, whether you installed it as a package or if you compiled it as shown above, so it can let you view .lit files for you.

Lastly, my personal view is that we should not patronize or encourage the buying and proliferation of any Microsoft format e-books. Let’s allow those formats to be unused or completely forgotten and demand free and open format e-book types such as unencrypted or un-DRMed PDF fiiles, HTML, plain ASCII text files, and others, including Open eBooks. Demand your e-books to be in those formats, open to the scrutiny of the general public. Demand not to be treated as if you were a criminal. Demand to have ridiculous laws like the DMCA repealed. Join the EFF. Let’s not just sit and let Microsoft and other proprietary formats prevent the access of information.

Information is important. And so are books.

Other References

Calibre installation instructions on other Linux distros and OSes

Linux Journal article on converting e-books in Linux

fbreader site