Warning: file( failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /mnt/data/home/www/www-bernaerts/plugins/content/displayfile/displayfile.php on line 121

Warning: Invalid argument supplied for foreach() in /mnt/data/home/www/www-bernaerts/plugins/content/displayfile/displayfile.php on line 123

Warning: file( failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /mnt/data/home/www/www-bernaerts/plugins/content/displayfile/displayfile.php on line 121

Warning: Invalid argument supplied for foreach() in /mnt/data/home/www/www-bernaerts/plugins/content/displayfile/displayfile.php on line 123

Ubuntu - Imposition or how to print a book from your documents



ubuntu-imposition-bookIn daily office life, who has not thought while printing a document :

It's a waste to print that document on A4 pages.
It would have been so handy to get it in a small A5 booklet.

Imposition is the clue !

Imposition is the process of arranging pages on printer's sheet, in order to obtain faster printing, simplified binding and reduced paper waste.

This guide will explain how to achieve that simple process of converting a plain document in portrait mode into a small A5 booklet printed on recto-verso A4 pages.

As an input, it takes a an LibreOffice, Ms-Office or PDF document and generates a PDF document ready for printing.

By default you will generate a document ready for printing on A4 pages, but some other formats like A3, A5, Letter, ... are also available (thanks to Robin idea).

It has been tested on Ubuntu 12.04 LTS, Ubuntu Gnome and Lubuntu 14.04 LTS, but it should work on any Linux flavor as long as you get pdfinfo, pdfbook and unoconv utilities.

If you don't need any technical explanation and you just want to be able to generate a PDF booklet straight from Nautilus file manager, you can jump to Complete installation procedure. It will provide a complete and simple installation script.

1. Some Explainations

Before going to the scripting part, lets understand the process.

Booklet Imposition main goal is simplicity. You should get :

  • no cutting
  • pages folded in half lengthwise
  • pages stapled centerline

On every recto-verso A4 pages you will print 4 pages of the original document :

  • The first and last pages are printed on one side of a standard A4 page
  • The second and penultimate page on the other side of that same A4 page
  • The page should be printed recto-verso on the long-edge

You have to repeat that first/last & second/penultimate relationship going thru the document, until you reach the middle of the document.


You can now simply fold in half lengthwise the printed pages and staple the binding line.

The result is a A5 booklet printed on A4 pages.

2. Install Packages

The booklet generation script will need four specific tools :

  • pdfinfo : to get number of pages from original document
  • pdfbook : to do the imposition job
  • mimetype : to determine the type of input document
  • unoconv : to convert an office document to a PDF file

Under Ubuntu, these tools are provided by the following packages (valid for Precise 12.04 and Trusty 14.04) :

# sudo apt-get install poppler-utils texlive-extra-utils mimetype unoconv

3. Imposition Script

The complete imposition job is done by a shell script.

This script takes the original document as a parameter. It adds blank pages at the end of the booklet if needed.

If no parameter is given, the scripts asks to select an input document.

Booklet is generated side to the original document, having the same name with -book appended at the end.


You can use following commands to install the script and declare it into your utilities main menu.

# sudo wget --header='Accept-Encoding:none' -O /usr/local/bin/generate-booklet
# sudo chmod +x /usr/local/bin/generate-booklet
# sudo wget --header='Accept-Encoding:none' -O /usr/share/applications/generate-booklet.desktop
# sudo chmod +x /usr/share/applications/generate-booklet.desktop

4. Access from Nautilus Menu

If you want your imposition script to be accessible straight from a right click menu on a LibreOffice, Ms-Office or PDF file in Nautilus, this can be done quite easily with Nautilus Actions.

If not already done, install Nautilus Action package and allow context menu icons :

# sudo apt-get install nautilus-actions
# gsettings set org.gnome.desktop.interface menus-have-icons true

You are now ready to declare a new Nautilus action menu.

This action is declared by creating a specific .desktop file under ~/.local/share/file-manager/actions directory (which may not exist).

Action file declares to Nautilus the action to be launched according to some specific mimetypes.


Following command creates action directory if it doesn't exist and declares Nautilus action :

# mkdir --parents $HOME/.local/share/file-manager/actions
# wget --header='Accept-Encoding:none' -O $HOME/.local/share/file-manager/actions/generate-booklet-action.desktop

All the needed steps are done to get a new  Generate booklet menu entry for PDF documents.

5. Complete installation procedure

If you want to install all needed tools and scripts in one go, you can run an all-in-one installation script available from my Github repository.

This script has been written and tested on Ubuntu 14.04 LTS. It will handle whatever installation and configuration described earlier in this article.

# wget --header='Accept-Encoding:none'
# chmod +x
# ./

6. Generate your PDF booklets

ubuntu-imposition-nautilus-menuAfter next login you should get a new  Generate booklet menu entry for PDF documents.

Everytime you select this menu on a PDF document, a A5 booklet is generated side to the original document.

You can now print it on any recto-verso printer in portrait mode, you will get your A5 booklet.

In case you detect any bug or if you have some update ideas which can benefit everybody, don't hesitate to contact me by email or to fork it on GitHub.


Hope it helps.

Signature Technoblog

This article is published "as is", without any warranty that it will work for your specific need.
If you think this article needs some complement, or simply if you think it saved you lots of time & trouble,
just let me know at This email address is being protected from spambots. You need JavaScript enabled to view it.. Cheers !

icon linux icon debian icon apache icon mysql icon php icon piwik icon googleplus