Hylafax Mailing List Archives

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Using MS Word to generate coversheet templates



When I first saw the SGI logo that is part of the standard FAX cover sheet
generated by HylaFAX 4.0pl0, I got a shock (I spent 8.5 years with Digital
just prior to installing HylaFAX on an ULTRIX machine).

In addition, the customer wanted their own logo and other details on the
cover sheet, so I investigated using MS Word to generate the FAX Cover sheet
(faxcover.ps in /usr/local/lib/fax).

The faxcover program that is run for a coversheet builds a postscript
dictionary with all the parameters that you give it and others it can figure
out, like:

  To:
  From:
  Re:
  Comments:
  Company:

etc. It then whacks this on the front of the file faxcover.ps mentioned
above. The deault faxcover.ps then uses the variables defined in the
dictionary to stick useful info on the front sheet.

In building a cover sheet for my customer, I used MS Word, and pulled in
their standard logo and placed it where they wanted it (I used frames for
some of the stuff they wanted). I also defined a footer on the page and
placed the legal notice and contact numbers on the bottom of the page. I
also noticed and was told by other people that you want a plain font without
serifs. I used helvetica, but still noticed that the numeral 8 would not
print correctly on the other end (the top of the 8 seemed chopped off, but
it is still recognizable as an 8).

The main thing I did however, was to build a table to contain the info
merged in from the dictionary that faxcover generates. This table allowed me
to right align the labels and left align the text, like so:


                     Date: One fine day
                       To: Sam Leffler, Jr
               Fax Number: 1234567
                     From: An appreciative HylaFAX user
                  Company: NS Computer Software and Services
                       Re: HylaFAX is just great
                 Comments: In fact, it is better than sliced bread

In fact, what I did for the cells that would contain the value of the field
indicated was to put in something like replace-with-date-field so that I
could easily find the places where variable substitution was needed.

Now, it turns out that with tables, the MS postscript driver (at least for
WfWg 3.11) generates the following for each row of the table:

        gs 435 94 19 306 CB
        46 333 86 (To:) 86 SB
        gr
        gs 1068 94 454 306 CB
        477 333 nnnn (replace-with-to-field) nnnn SB
        gr

Where nnnn is the length that the text occupies in points.

That is, it generates two groups of postscrip, with a graphics save, a print
sequence and a graphics restore. Unfortunately the SB requires the lenght in
points of the text before and after the text or it does strange things, like
squish the text, or print like t      h      i     s.

So what I did was to change the postscript to this:

        gs 435 94 19 306 CB
        346 333 86 (To:) 86 SB
        gr
        gs 1068 94 454 306 CB
        477 333 to MAKEREAL FIXLEN SB
        gr

That is, for each block of 6 ps statements, I ignored the first part, and
changes the replace-with-xxx-field with the name of that field as specified
in the dictionary that gets plugged on the front. I also added those two ps
functions MAKEREAL and FIXLEN.

Here are all the definitions that I stick at the front of the coverpage.ps file:

/covpaglen 1 def
/nullstring () def
/MAKEREAL {
dup nullstring eq { (   ) exch pop } if
} def
/FIXLEN {
dup stringwidth pop exch dup stringwidth pop
} def
/ADDCPL {
dup length 1 add /cptemp exch string def cvi covpaglen add cptemp cvs
} def

The first two just define some constants. MAKEREAL checks to see if the
variable has a null value, and if so, sticks a few spaces on the stack so
that SB wont barf. FIXLEN computes the length in points of the string on the
top of the stack (using the currently defined font) and sticks that value on
the stack before and after the string so SB will work OK.

ADDCPL makes the page count correct in those cases where you want the page
count to include the coverpage. Of course, page count is estimated by
ghostscript using the comments passed to it, but what the hell.

The block of ps that specifies the page count looks like this:

gs 435 94 19 776 CB
270 803 162 (Pages:) 162 SB
gr
gs 435 94 19 870 CB
62 897 370 (\(including this\)) 370 SB
gr
gs 1068 94 454 776 CB
477 803 page-count MAKEREAL ADDCPL FIXLEN SB
gr

I also did some extra work to get the comments field printed out split up
the way faxcover generates it, but it should be obvious how to do that by now.

I hope that people find this discussion useful.
Regards
-------
Richard Sharpe, sharpe@ns.aus.com
NS Computer Software and Services P/L, 
Ph: +61-8-8281-0063, FAX: +61-8-8250-2080, WWW: http://www.ns.aus.com
NS is an OS-neutral, equal-HTTP-server opportunity employer!



Home
Report any problems to webmaster@hylafax.org

HylaFAX is a trademark of Silicon Graphics Corporation.
Internet connectivity for hylafax.org is provided by:
VirtuALL Private Host Services