Tag Archives: pdf

Reading pdf files from the terminal with less

The good old less command can be used to open more than plain text files. All you need is to set the LESSPIPE environment variable to pipe the /usr/bin/lesspipe script in your .bashrc or .zshrc file. In most systems, the lesspipe script is pre-installed. Otherwise you can download it from here.

export LESSOPEN='|/usr/bin/lesspipe %s'

Now simply open your pdf files with less.

less abc.pdf

Besides from pdf files you can pipe in compressed files (like tar.gz, zip, rar, etc), ISO files and even .doc files. But who uses .doc files anyway? :mrgreen:

Creating booklets out of PDFs

This friend of mine wanted to print a PDF as a booklet, i.e. with two pages printed in each A4 page so that it can be folded to make an A5 sized booklet. It works as shown in this pic. This requires a software that can rearrange the pages accordingly. I had heard of this tool called Booklet Creator but, even though it’s advertised as free, the free version lets you convert only up to 6 pages. And the license is $20. Ridiculous.

What do you do when you need to find an alternative to a software? Check out AlternativeTo.net of course. It led me to this free and open-source tool called pdfbook that lets you do exactly the same. It works in Linux only though (it may work on Windows but will need some work). Also, the tool has some dependencies which need to be installed. In Linux this is usually not much of a problem thanks to package managers. If you’re on Ubuntu/Debian, the steps to install pdfbook is as follows:

  1. sudo apt-get install texlive-latex-base texlive-latex-recommended
  2. Download the pdfbook tarball from here and extract
  3. Go to the extracted directory and install using make install

Now pdfbook is ready to use. The following command will create a booklet:

./pdfbook -2 original.pdf destination.pdf