How to convert a man page into PS, PDF or DVI

Posted on 15.10.2009 by Kim N. Lesmer.
Man pages (short for "manual pages") are the extensive documentation that comes preinstalled with almost all substantial Unix-like operating systems. The Unix command used to display them is "man". Each page is a self-contained document. This how-to is about how to convert a man page into a PS or PDF document.

How to convert

The man page for mplayer is very extensive, and I wanted to convert it into a PDF file, so that I could print it out and read it at a later time.

It turned out to be very easy to convert man pages into other formats.

First locate the man page that you want to convert (in this case the man page for mplayer):

$ whereis mplayer
mplayer: /usr/bin/mplayer /etc/mplayer /usr/share/mplayer /usr/share/man/man1/mplayer.1.gz

On Debian the mplayer man page is located in /usr/share/man/man1/

Converting the man page into PS

$ man -l -Tps /usr/share/man/man1/mplayer.1.gz > mplayer.ps

Converting the man page into PDF

In order to do this, you need to have the ps2pdf package installed.

On any Debian derived distribution you can installed the package using:

# apt-get install ps2pdf

Next you can convert the man page into PDF using this command:

$ man -l -Tps /usr/share/man/man1/mplayer.1.gz | ps2pdf - mplayer.pdf

What this command does is actually to convert the man page into PS, and then pipe that into the ps2pdf program that then convert the PS file into PDF.

Converting the man page into DVI

In order to do this, you need to have the groff package installed:

# apt-get install groff

Next you can convert the man page into DVI using this command:

$ man -l -Tdvi /usr/share/man/man1/mplayer.1.gz > mplayer.dvi

If you have any comments or corrections feel free to email them to me.