Getting more printable PDFs from texinfo manuals

Texinfo manuals are used primarily by various GNU projects like Glibc, gcc, gdb, etc. Texinfo is an extremely powerful format for writing high quality professional documentation and can be easily converted to HTML, PDF, Docbook XML and various other formats. The language features tex macros which are quite easy to pick up, and much easier to hand write as compared to the new fangled XML formats.

However, my pet grouse for a long time was that the PDFs, which look excellent on screen don’t seem to print too well on paper. A close examination and various posts on mailing lists like this made me discover the fact that this is primarily because of the Computer Modern fonts used by default by texinfo.

Interestingly, the GNU Press folks which print FSF manuals customize the PDF by modifying fonts etc. so that they print better. At the very minimum, they replace the Computer Modern font with Palatino which prints better. And in the FSF’s spirit of sharing code, these customizations are available for download at the Savannah Gnupress project cvs repository. A look here and at some brief instructions here let me arrive at these simple steps to generate a texinfo PDF with palatino fonts.

  1. Check out the CVS sources of GNU Press from the savannah repository. Here I am checking out in my home directory.

    $ cvs -z3 co gnupress
  2. Download the texinfo sources that you want to generate PDF from.

  3. The first time, generate a pdf the normal way using texi2pdf.

    $ texi2pdf --clean gdb.texinfo

    This step is important as sometimes the document is broken and cannot be parsed by texinfo. Trying to use the gnupress’s code will only make it more difficult to troubleshoot and will introduce an unnecessary variable to consider while debugging. I have seen the downloadable libc texinfo sources as broken. So this is a realistic possibility.

  4. Modify the texinfo source code by adding just this one line immediately after the line containing \input texinfo at the top of the file.

    @input palatino

    So effectively, this would the how the top of the document looks after you added the line.

     \input texinfo      @c -*-texinfo-*-
     @input palatino
     @c Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,
     @c 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
     @c Free Software Foundation, Inc.
     @c %**start of header
     @c makeinfo ignores cmds prev to setfilename, so its arg cannot make use
     @c of @set vars.  However, you can override filename with makeinfo -o.
  5. Generate the pdf using texi2pdf and the gnupress code. I checked out their code in my home directory. If you checked out elsewhere, adjust paths accordingly.

    $ texi2pdf --clean   -I ~/gnupress/texpress/ -I ./ gdb.texinfo
Removing encryption from (legitimate!) PDF files on Ubuntu Akamai awesomeness and Opendns lameness