Hylafax Mailing List Archives
|
[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
[hylafax-users] Solved Faxmail unicode text, gif, jpg attachment problems
After suffering several days from web browsing, mail list seeking and
reference searching.
I am able to send fax with non-ASCII code (big5, GB, UTF8, shift-jis) email
and attachments (jpg, gif, tif) together. However, it still fails in sending
(postscript + body text) together.
In order to share my experience to all hylafax user. I write the procedures
here for your comments.
============================================
Enable sending fax with Plain TEXT, JPEG, GIF and TIFF ...etc
============================================
1. Adding a line in /etc/hylafax/hyla.conf to let hylafax knows where the
MIME decoder located.
MIMEConverters: /usr/local/sbin/faxmail
2. Create the Type directories that your binary file belongs to.
(Type/Subtype)
For example, in email
a) jpg refers to "application/octet-stream" ,therefore, you should creat a
directory called "application" in the /usr/local/sbin/faxmail directory
b) gif refers to "application/octet-stream", the same as jpg
c) tiff refers to "image/tiff", creat an "image" directory
d) txt refers to "text/plain", creat a "text" directory
3. Download and install the appropiate converter
For JPEG, We can download a jpeg to postscript converter, jpeg2ps (you can
search it from web).
For GIF, I use gif2ps.
For TIFF, tiff2ps
For TXT, uniprint (From the package of Yudit ) and a unicode font (
cyberbit.ttf )
4. Here is the most important and hardness part (you should be able to write
some shell script or perl script)
----------------------------------------------------------------------------
For TIFF, create a file "tiff" in /usr/local/sbin/faxmail/image and chmod
755 it.
Here is the contain of the file "tiff"
################################
#!/bin/bash
/bin/echo " "
/bin/echo "showpage"
/usr/bin/tiff2ps -a $1 | /usr/local/sbin/faxmail/filter.pl
################################
----------------------------------------------------------------------------
----------------------------------------------------------------------------
For JPEG and GIF, it is more complicated. Since both of the format have the
same subtype.
Therefore, the script should able to distingish them.
Creat a file "octet-stream" in /usr/local/sbin/faxmail/application and also
chmod 755 it.
Here is a sample script of "octet-stream"
################################
#!/bin/bash
# #This part is to convert GIF
if [ "`cat $1 |grep GIF`" ]; then
echo " "
echo "showpage"
/usr/bin/gif2ps $1 | /usr/local/sbin/faxmail/filter.pl
# # Here is the jpg converting
else
echo " "
echo "showpage"
/usr/bin/jpeg2ps -q $1 | /usr/local/sbin/faxmail/filter.pl
fi
##################################
----------------------------------------------------------------------------
----------------------------------------------------------------------------
For Plain text, creat the file "plain" in /usr/local/sbin/faxmail/text and
chmod 755 it.
Here is the sample script of "plain"
##################################
#!/bin/bash
/usr/bin/uniprint -font cyberbit.ttf -in $1 -out /tmp/tmptxt > /dev/null
2>&1
echo " "
echo "showpage"
cat /tmp/tmptxt | /usr/local/sbin/faxmail/filter.pl
rm /tmp/tmptxt
##################################
Remark:
This script also convert the body text of email.
You can customize the encoding of uniprint to BIG5, SHIFT-JIS, GB ..etc, but
don't remember to use an appropiate font.
You can download fonts accroding to your encoding from web (the true type
font installation guide is in yudit package)
Use unicode in the body text when sending email.
----------------------------------------------------------------------------
----------------------------------------------------------------------------
To let the above script run properly, an extra perl script is need.
Without this script, you can already fax your stuff, but the problem is that
blank sheet will automatically insert between each file.
A result of 3 page fax becomes 6 page or even more.
This is due to the insert mechanism of faxmail.
Normally, faxmail will generate the first page in postscript with TO and
FROM information.
Any attachments will insert in the middle of the postscript.
However, in postscript syntax the word "showpage" is an indicator of end of
page.
Once the postscript that generated by the above process is inserted to the
middle of first page.
The whole file is corrupted, because the showpage is placed in the wrong
place.
This will result in print page without correct display of your file but a
blank page.
Therefore, I use some tricks here.
I print a "showpage" before each attachment to indicate the end of page.
and then I eliminate the last "showpage" at the bottom of each attchments.
After that I got everythings right.
OK. Come back to out procedure.
Creat a file "filter.pl" in /usr/local/sbin/faxmail directory and chmod 755
it.
Here is the code.
##################################
#!/usr/bin/perl
# Read from the standard input
@text=<STDIN>;
$size=@text;
# Count the number of "showpage"
$count=0;
for($i=0;$i<=$size;$i++){if($text[$i] =~ /showpage/){$count++;}}
# Discard the last line that contain "showpage"
$num=1;
for($i=0;$i<=$size;$i++){
if($text[$i] =~ /showpage/){
if($num!=$count){$num++;}
else{$text[$i]=~s/showpage//g;}
}
print $text[$i];
}
##################################
----------------------------------------------------------------------------
Now you should be able to print GIF, JPEG and TIFF attachment with body
message.
You can also imprement the HTML2PS to allow html attachment.
However, html2ps as I know is not unicode compatable.
Thanks for any comment.
Hope it can help all of you.
Goldfish
____________________ HylaFAX(tm) Users Mailing List _______________________
To subscribe/unsubscribe, click http://lists.hylafax.org/cgi-bin/lsg2.cgi
On UNIX: mail -s unsubscribe hylafax-users-request@hylafax.org < /dev/null