Converting Linux HOWTOS into Book format.

By Mark Nielsen

  1. Introduction
  2. Perl script converting the postscript files.
  3. Conclusion
  4. References


I wanted to print out Linux HOWTOS into book format. However, I am not fond of manually converting the howtos. Instead, since all the howtos are available in postscript format, I figured out that I could download the postscript files on a regular basis and use various tools to convert the postscript files into book formatted postscript and pdf files. I accomplished this with a relatively small perl script using a variety of unix tools. I plan on have a cron job run at least once a week to update the books.

Perl script converting the postscript files.

The perl script is in this section, and you can also get the perl script here.


# cp Makefile.unix Makefile
# ln -s /usr/bin/perl /usr/local/bin/perl
# mkdir -p /usr/local/share/man/man1
# /usr/local/bin/psbook

#system ("lynx --source > /tmp/psutils.tar.gz)";
# system ("cd /tmp; tar -zxvf psutils.tar.gz; cd psutils; cp Makefile.unix Makefile");
# system ("ln -s /usr/bin/perl /usr/local/bin/perl; mkdir -p /usr/local/share/man/man1");
# system ("cd /tmp/psutils; make; make install; ln -s /usr/local/bin/psutils /usr/bin/psutils");

# Ignore the lines above, unless you don't have psutils. 
# I keep the lines above just so I remember how I installed psutils.

my $TempFile1 = "/tmp/";
my $TempFile2 = "/tmp/HOWTO_Convert_1.pdf";
my $SourceDir = "/root/HOWTO";
my $Destination = "/root/HOWTO_Books";
my $ZippedPDF = "/root/HOWTO_books_pdf.tgz";
my $ZippedPS = "/root/HOWTO_books_ps.tgz";

if (!(-d $Destination)) {system "mkdir $Destination";}

print "Downloading howtos from\n";
system ("lynx --source > $SourceDir/Linux-ps-HOWTOs.tar.gz");
system ("cd $SourceDir; tar -zxvf Linux-ps-HOWTOs.tar.gz"); 

my @Files = <$SourceDir/*.ps.gz>;

foreach my $File (@Files)
  my $command="gunzip -c $File | /usr/bin/psbook -s4 | mpage -2 > $TempFile1";
  print "Executing psbook and mpage on $File\n$command\n";
  system ($command);
  $command = "ps2pdf $TempFile1 $TempFile2";
  print "Executing ps2pdf\n$command\n";
  system ($command);

  my (@Temp) = split(/\//,$File);
  my $NamePDF = pop @Temp;
  my $NamePS = $NamePDF;
  $NamePDF =~ s/\.ps\.gz$/\.pdf/;
  $NamePS =~ s/\.ps\.gz$/\.ps/;
  my $NewPS = "$Destination/$NamePS";
  my $NewPDF = "$Destination/$NamePDF";

  system ("mv $TempFile2 $NewPDF"); 
  print "Created the book-formatted howto, $NewPDF\n";
  system ("mv $TempFile1 $NewPS");
  print "Created the book-formatted howto, $NewPS\n";

print "Creating zip files $ZippedPDF and $ZippedPS\n";
system ("tar -zcvf $ZippedPDF $Destination/*.pdf");
system ("tar -zcvf $ZippedPS $Destination/*.ps");


This is just a simple perl script I use to download and convert the postscript HOWTOS. My future goals involve,
  1. Using LWP in Perl instead of Lynx. Simple enough.
  2. Converting the entire Perl script into Python.
  3. Better error checking if the files don't get downloaded or if the conversion doesn't work.
  4. Create objects where I accept text, tex, postscript, pdf, or other formats that can be converted into postscript fairly easily and then into book format.
For now, my simple perl script works out just fine. I am interested in converting other documents for people provided that the documentation falls under some form of free documentation, like Licenses For Documentation located at


  1. 10/2000 Micro Publishing: Part 3 , by Mark Nielsen .
  2. 7-1-2000 Micro Publishing, part II (Mark's Update)
  3. 12-1999 -- Micro Publishing.
  4. If this article changes, it will be available here

Mark works as an independent consultant donating time to causes like, writing articles, writing free software, and working as a volunteer at

Copyright © 4/2001 Mark Nielsen