Search

Monday, April 12, 2010

Merge fields in hylafax sendfax

 

We occasionally need to merge variables (e.g., customer name, customer number, etc.) in fax contents.  There is no easy way to merge information within the page data.

 

However, the hylafax sendfax command supports parameters for merging in cover page.   These parameters are denoted by special variables in the postscript file used to generate cover page.  

%% to   destination person

%% from   sending person

%% to-company       destination company

%% from-company  sender's company

%% to-location  destination geographic location

%% from-location sender geographic location

%% to-voice-number person's voice phone number

%% from-voice-number sender's voice phone number

%% to-fax-number destination fax phone number

%% from-fax-number sender's fax phone number

%% comments  unbroken comment string

%% commentsX  X'th line of comments

%% regarding  Re: subject

%% page-count  # pages other than cover page

%% pageWidth  page width in millimeters

%% todays-date  current date and time

%% pageLength  page length in millimeters

 

Following the steps below to create a custom cover page.

Print the required cover page to tiff e.g infile.tif

  • Make sure tiff is output as black and white (can use Zan printer driver to output to tiff)
  • Dpi 200x200
  • Paper size is A4
  • tiff2ps –e infile.tif > job_cover.ps

Based on the add-on.ps below, create a specific add-on.ps for this cover page

·        the add-on.ps is an eps to specify location and font to print variables passed from faxcover()

·        the center of coordinates is the left bottom corner of the fax cover

·        one inch equal to 72 points

·        for example, the statement "72 72 moveto to-company show" instructs postscript to print the variable to-company at 1 inch above and right relative to the bottom left cornet

 

Append /tmp/make_faxcover/add-on.ps to job_cover.ps

  • just before the 'showpage' operator
  • if no 'showpage' operator exists, add it to the end of job_cover.ps as below.

%%

showpage

%%Trailer

%%Pages: 1

%%EOF

  • refer to the system default faxcover.ps for available fonts

 

In sendfax, use –C full-path-of-job_cover.ps to specify the cover template

 

Sample add-on.ps

%% whfc.template---------------------------START HERE

%%

%% Place this at the end of your postscript file, immediately above the

%% showpage operator.

%%

%% The initmatrix operator resets the way the text is placed.  Without it

%% You may find your text upside down, sideways, or worse.

%%

%% The scale operator resets your scale to points (72 per inch)

%%

%% The garbage in front of the findfont operator is postscript's way of

%% describing a microsoft font.  You can use any of the fonts on your

%% document, but it will be necessary to get the code first.  Search for

%% the name of the font (exp. Arial).  The description code will be

%% close by.

%%

%% The scalefont setfont lines set the point size for the font and tells

%% postscript to use that font for the following lines

%%

%% The moveto operator moves from the bottom left hand corner x number

%% of points to the right (the first number) and y number of points up

%% (the second number)

%%

%% The fields placed are described below and are printed with the show

%% command.  This example uses 4 comment lines; your coverpage may have

%% more.  I have not used all of the fields, additionally, I believe

%% that the pageLength and pageWidth operators are set by the original

%% postscript generator, so I didn't use them.

%%

%% Make sure to download all fonts when you print your coverpage to disk!

%%

%% I didn't have any luck figuring out the CommentsX crapola, (Bug 87??!!)

%% So I just used four lines in my comment section.  If you're using WHFC,

%% this would correspond to the first four lines of the comments box

%% If you want more, just make them.

%%

%%

%%

%% to   destination person

%% from   sending person

%% to-company       destination company

%% from-company  sender's company

%% to-location  destination geographic location

%% from-location sender geographic location

%% to-voice-number person's voice phone number

%% from-voice-number sender's voice phone number

%% to-fax-number destination fax phone number

%% from-fax-number sender's fax phone number

%% comments  unbroken comment string

%% commentsX  X'th line of comments

%% regarding  Re: subject

%% page-count  # pages other than cover page

%% pageWidth  page width in millimeters

%% todays-date  current date and time

%% pageLength  page length in millimeters

%%

%%

%% initmatrix as per instructions above

%%

initmatrix

%%

%% initialize the scaling

%%

1 1 scale

%%

%% The following is an instruction to load a particular font

%%

%%/Helvetica-Bold findfont

%%

%%

%%

%% Now let's set the size

%%

%%10 scalefont setfont

%%

%%

%% Now move to where we're going to place it

%%

%%130 501 moveto

%%

%%

%% Now print the "to" field on the cover page

%%

%%to show

%%

%%

%%

%% Now the to-company field

%%

/Helvetica-Bold findfont

10 scalefont setfont

72 72 moveto to-company show

%%

/Times-Bold-SHOWISO findfont

12 scalefont setfont

144 144 moveto to-company show

%%

/Courier findfont

14 scalefont setfont

216 216 moveto to-company show

%%

/Courier findfont

16 scalefont setfont

288 288 moveto to-company show

%% at 4.5 inch

/unifont findfont

10 scalefont setfont

323 323 moveto to-company show

%%

%% The from line

%%

%%130 474 moveto

%%from show

%%

%%

%% Now change the font (Hey, why not?)

%% Of course if you can't find the "MSTT_Whatever" string in your postscript

%% Then naturally you can't use that font.  Did I need to say that?

%%

%%/Times-Bold-SHOWISO findfont

%%

%%

%% Scale the font again

%%

%%10 scalefont setfont

%%

%% Ok, You can figure out the rest

%%

%%

%%380 633 moveto

%%todays-date show

%%520 589 moveto

%%page-count show

%%/Times-Bold-SHOWISO findfont

%%10 scalefont setfont

%%220 98 moveto

%%regarding show

%%/Times-Bold-SHOWISO findfont

%%10 scalefont setfont

%%130 420 moveto

%%comments1 show

%%130 393 moveto

%%comments2 show

%%130 366 moveto

%%comments3 show

%%130 339 moveto

%%comments4 show

%% whfc.template---------------------------END HERE

%%/Helvetica-Bold findfont

%%/Helvetica-Bold-SHOWISO exch definefont pop

%%/Helvetica findfont

%%/Helvetica-SHOWISO exch definefont pop

%%/Courier findfont

%%/Courier-SHOWISO exch definefont pop

%%/Times-Bold findfont

%%/Times-Bold-SHOWISO exch definefont pop

%%/Helvetica-SHOWISO findfont 14 scalefont setfont

%% /Helvetica-Bold-SHOWISO findfont 18 scalefont setfont

%%/Helvetica-Bold-SHOWISO findfont 24 scalefont setfont

%%/Times-Bold-SHOWISO findfont 10 scalefont setfont

%%/Helvetica-Bold-SHOWISO findfont 24 scalefont setfont

%%/Helvetica-Bold-SHOWISO findfont 24 scalefont setfont

%%/Helvetica-Bold-SHOWISO findfont 24 scalefont setfont

%%

%%

%%

 

 

No comments:

Post a Comment