Re: Faxing

2006-01-23 Thread Alan Fry
I was intrigued by the original question and have done some  
experiments on this G4 running Mac OS X 10.4.4.


Firstly I set the machine up so as to be able to send faxes from  
applications using the Mac OS Print-PDF-Fax PDF… built in facility.  
I have a broadband connection (ethernet modem) so it was necessary to  
add a serial modem to dial up the remote fax machine's number. A USB  
modem left over from the old internet dial-up days seemed promising.


There is on http://www.apple.com/support/ a very clear concise  
document Mac OS X 10.4: Adding a Bluetooth fax device. Although a  
USB modem is not quite the same animal as a Bluetooth modem, the  
recipe for the one works for the other. There is no point rehearsing  
the 12 steps set out in that document here: anyone interested should  
download the Apple document.


Having done this, Print-PDF-Fax PDF was found to work perfectly  
with a number of applications, for instance BBEdit. This established  
that the machine was capable of sending faxes. However it does not  
settle the question of how to send faxes from within a Perl script.  
If the document's application is scriptable a fax might be sent by an  
AS to work the 'Print' facility, and that AS could be dispatched from  
Perl. But that is by no means a good general solution to the problem.


However 'efax' does offer a more general solution. There are, I  
think, various ways to call Unix from Perl. I have tended to write a  
shell script for the Unix function, calling that from the Perl script  
by 'tell application Terminal -- do script() -- end tell'. So the  
first step was to get 'efax' working from the terminal.


By default 'efax' expects to find '/dev/cu.modem', which on this  
machine does not exist. However 'ls /dev/' revealed (amongst a heap  
of stuff) an entry 'cu.usbmodem08141'. Using this in place of the  
default results in a command line:

efax -d /dev/cu.modem08141 -t [remote fax number] file.tif
That worked fine. (I am lucky that my ISP, demon, provides me with a  
fax number for incoming faxes which it then e-mails to me, which I  
can send faxes to myself for test purposes. Otherwise, I suppose, you  
would need a local good friend with a fax machine in order to do the  
experiments…)


The question then arose how to obtain a faxable version of the  
document in question. This is most complex part of the problem simply  
because of the huge number of possible document formats. In my own  
small world I restrict the range to Postscript and PDF documents.  
Postscript is useful because firstly one can very easily output '.ps'  
files from Perl (for instance the perl script 'pod2ps' does this) and  
secondly within Mac OS X every application can save its document as a  
PDF file. Hence, On the whole, I need only deal with '.ps' and '.pdf'  
files.


The question then arises as to how to convert these formats to G3  
compressed '.tiff' files required by 'efax'. Now there is a companion  
to 'efax' by the name of 'efix' which can do this but I must confess  
so far I have been unable to make it work. However it appears that it  
is effectively a front end for ghostscript, and therefore it seems to  
me more sensible to use 'gs' directly. Even if one opts to use 'efix'  
ghostscript must be installed. The mantra for converting a file to a  
faxable format is:
	gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=tiffg3 -dTextAlphabits=4 - 
dGraphicsAlphaBits=4 -sOutputFile=outfile infile
Obviously one has complete freedom of choice about the outfile name  
and extension, but 'gs' determines the infile format from the infile  
extension I believe. By this means '.ps', '.pdf', '.txt' and a whole  
heap of graphics formats can be converted to fax format. Again, from  
Perl a shell script can be invoked by a AppleScript call to the  
Terminal.


As Bill Stephenson says below there is a front end for both 'efax'  
and 'efix' going under the name 'fax'. The command 'fax make file'  
will produce a fax format file with the same name as file with .001, . 
002 etc. appended. It uses 'efix', which in turn uses 'gs'. I can see  
no advantage in this. Indeed there are snags with 'fax': for instance  
it expects a US letter page size and truncates an A4 postscript page.  
There appears to be no way of controlling page size. Similarly the  
commmand 'fax send file' fails because it uses 'efax' with all  
default settings, including the default serial modem. There appears  
to be no way of overriding the 'efax' defaults from 'fax'.


I have not tried (yet) the suggestion of piping a file to 'lpr' --  
certainly the serial modem appears in 'lpinfo' -- so it might well  
work. However I think everything you might want to do from within  
Perl can be done quite simply by firstly using 'gs' to convert the  
file to faxable format and sending the fax by 'efax'. In both cases a  
suitable shell script can be invoked from within a perl script by an  
AppleScript 'do script' command.


I hope this may be 

Re: Faxing

2006-01-23 Thread Bill Stephenson

On Jan 23, 2006, at 5:09 AM, Alan Fry wrote:

I was intrigued by the original question and have done some 
experiments on this G4 running Mac OS X 10.4.4.


snip


Wow, thanks for sharing what you've learned! Admittedly, I haven't had 
much time to play with this since I asked that question but your reply 
puts me way ahead of where I was then. I'd also like to thank everyone 
else that replied. If I get my Fax the House script finished I'll 
post a copy of it.


Kindest Regards,

--
Bill Stephenson