[ Prev ][ Table of Contents ][ Front Page ][ Talkback ][ FAQ ][ Next ]

"Linux Gazette...making Linux just a little more fun!"

Virtual fax to pdf files with

By Mark Nielsen

  1. References
  2. Introduction
  3. Getting the fax number
  4. What is in the email?
  5. What do we do with the tiff files?
  6. Scripts.
  7. Conclusion




The idea is very simple. Sign up with a fax service which provides you a phone number and they will forward all faxes to that number to you in the form of email. Take the fax in the email and convert it into a pdf file on your webserver so that you can download, or perhaps have it automatically dump the fax to a printer.

This is very nice if you want to create a virtual office. Many a independent consultant might be interested in this.

Getting the fax number

Go to You can figure it out. Just get their free basic account. I believe there are other free fax services out there, but I have looked around a lot.

What is in the email?

The email you receive will contain tiff formatted graphic files. They are converted to text in the email. You will need a program to extract the tiff files out of the email and convert the tiff files from text back to binary.

Once you have extracted the tiff files out of the email messages, you can do with them whatever you want. For this article, we will convert them to pdf files and put them in a web directory for easy download.

What do we do with the tiff files?

Okay, you need a program called uudeview, or some other program, which will easily extract the tiff files out of the email messages. Then, you will need to convert the tiff files to postscript. Then you will need to convert the postscript files to pdf. Then you will need to put the pdf files in a web directory. Here is an example of how to do this,
  ### Copy the mail over to a temporary file. 
cp /var/spool/mail/Username File.mail
  ### Extract the tiff files. 
uudeview File.mail
  ### Let us assume the tiff file is extracted as the name MyFile.tiff
  ### Convert it to postscript
tiff2ps MyFile.tiff >
  ### Convert it to pdf
ps2pdf TempFile.pdf
  ### move it
mv TempFile.pdf /www/docs/pdf/TempFile.pdf 
That is how you can do it manually. However, we want to automate the process. Two scripts in the next section will do that.


These scripts clean up temporary files. You may not want to delete the email messages, in which case, someone will have to modify this perl script. (text version)

## We assume you have uudeview installed. 
## We assume you have a public_html directory which your webserver has been
## properly configured to see. 

### This perl script is not properly secured since it is possible to make
### a weird configuration for the name of the fax file, which in theory
### could mess up the command line statements. Use at your own risk.   

my $User = "Mu_Username";
my $Temp = "/home/$User/Temp/fax";

system "cp /var/spool/mail/$User /home/$User/Temp/";
system "cp /dev/null /var/spool/mail/$User";
system "/usr/bin/uudeview -o -i -d -p /home/$User/tiff/ /home/$User/Temp/fax";
system "cp /dev/null /home/$User/Temp/fax";

my @Old_Pdfs = </home/$User/public_html/pdf/*.pdf>; 
my $No = @Old_Pdfs;

foreach my $File (</home/$User/tiff/*.tif>)
  my $Ps = $File;
  $Ps =~ s/\.tif/\.ps/g;
  $Ps =~ s/tiff/ps/; 
  system "/usr/bin/tiff2ps $File > $Ps";

  ### If you want to print this, uncomment
  #   system "lpr $Ps";

  my $Pdf = $Ps;
  $Pdf =~ s/\.ps/\.pdf/g;
  system "/usr/bin/ps2pdf $Ps $Pdf";

  ### Either choose to keep the default name of the file or number it
#  system "mv $Pdf /home/$User/public_html/pdf/";
  system "mv $Pdf /home/$User/public_html/pdf/$No.pdf";

  system "rm $Ps $File;";
Here is the crontab file you will need. run the command
crontab Crontab
in order to get to be automated.

0,15,30,45 * * * *   /home/UserName/ >> /home/UserName/cron_log 2>&1


This is very easy way to get your virtual fax to be automated and converted into something that is easy to read. Having a virtual fax number is nice because it saves you money by not having to have a phone number. Every roaming consultant needs this.

Phil Hunter from COLUG first told me about this a year or two ago. He just dumps the faxes to a printer. It wasn't of much use then when I had an office and a fax machine, but I have found it useful since I moved out to California. My next goal is to send a fax through a modem, and then I will be able to send and receive faxes when I am not in my office in the Bay Area.

Copyright © 2000, Mark Nielsen
Published in Issue 58 of Linux Gazette, October 2000

[ Prev ][ Table of Contents ][ Front Page ][ Talkback ][ FAQ ][ Next ]