SIMPLE2 – add font control and text

Top  Previous  Next

 

This is a somewhat more advanced rule set than simple1, demonstrating how to add fonting, justification, and text movement to the job.  Additional notes are supplied to highlight these concepts.  To prevent simple1's detection code from selecting the job, add a –r option to the command line:

 

uf90c –i sample1.txt –f simple.rul –r simple2 –p pdf –o client:simple2.pdf

 

[simple2]

# to use this rule set, you need to FORCE the rule set with the -r option

# or remark (#) out the detect command in the rule sets above.

#

# This rule set takes the rule set above and improves it by adding

# fonting and justification.

 

# It also cuts and pastes the invoice #/date/pg fields which allows

# more room for company name and address to be centered

 

# Also notice first use of relative expression in a text command to fix

# a problem with fonting a series of rows. Put a # in front of this

# command to see the problem that occurs. See memo section.

#

 

detect 61,5,"~../../..  ......."        # invoice date and #

detect 9,11,"~......"                   # customer code

detect 10,21,"~../../.. ......"         # ord date and cust code

 

cols 80                                 # max output columns

rows 66                                 # max output rows

 

 

The header section has changed to use center and right justification.  Note the use of cols=79 in each text command, which tells UnForm the bounds of the justification region.  For example, the text "Company Name" is centered in the region starting at column 1, for 79 columns.

 

# header section

cbox .5,.5,80.5,66.5,5

image 1,1,12,6,"sdsilogo.pcl"

text 1,2,"Company Name",univers,14,bold,center,cols=79

text 1,3,"Company Address\nCompany City, St Zipcode\nCompany Phone",univers,12,bold,center,cols=79

text 1,6,"Web: www.myweb.com\nEmail: sales@myweb.com",univers,11,bold,center,cols=79

text 1,2,"INVOICE",univers,16,bold,right,cols=79

 

 

The Invoice number section is re-formatted here, by first drawing a new, vertically-oriented grid and heading section, then by using text commands with expressions that use the cut() function.  The expression is indicated by the curly braces, such as {cut(61,5,8,"")}, which directs UnForm to resolve the function as the job processes each page.  In the line starting with "text 75,5", the data from the input stream at column 61, row 5, for 8 characters is cut and replaced with nothing (""), and it becomes the value printed at column 75, row 5.
 
Further down, in the bill to/ship to section, is an example of the mcut() function, which cuts multiple lines and replaces them with "", retaining line breaks and trimming each line of leading and trailing spaces.

 

# invoice # section

cbox 67,4,80.5,10,1,crows=6 8,ccols=74::20

text 68,5,"Date",univers,italic,10

text 68,7,"Invoice",univers,italic,10

text 68,9,"Page #",univers,italic,10

# cut data from old position and place in new

text 75,5,{cut(61,5,8,"")},cgtimes,bold,10

text 75,7,{cut(71,5,7,"")},cgtimes,bold,10

text 75,9,{cut(79,5,2,"")},cgtimes,bold,10

 

# bill to / ship to section

cbox .5,10,80.5,18.5,5,ccols=7::20 43.5 50::20

text 2,12,"Sold To",cgtimes,italic,10,center,cols=5

cfont 8,11,40,11,cgtimes,bold,10,left

cfont 8,12,40,15,cgtimes,bold,10                         # sold to address

text 45,12,"Ship To",cgtimes,italic,10,center,cols=5

cfont 51,11,80,11,cgtimes,bold,10,left

text 51,12,{mcut(51,12,30,4,"","Y","Y")},cgtimes,bold,10

 

# ribbon section

cbox .5,18.5,80.5,22.5,5,crows=20.5::20,ccols=9 18 25 65

# special internal grid in ribbon box

cbox 29,18.5,65,21.5

cbox 42,18.5,56,21.5

text 1,19,"Order\nNumber",univers,italic,10,center,cols=8

text 10,19,"Order\nDate",univers,italic,10,center,cols=8

text 19,19,"Cust.\nNumber",univers,italic,10,center,cols=6

text 26,19,"Sls\nPrs",univers,italic,10,center,cols=3

text 30,19,"Purchase\nOrder No.",univers,italic,10,center,cols=12

text 43,19,"\nShip Via",univers,italic,10,center,cols=13

text 57,19,"Ship\nDate",univers,italic,10,center,cols=8

text 66,19,"\nTerms",univers,italic,10,center,cols=14

 

 

This section changes the fonts of the input data stream in the invoice ribbon section.  For example, the first cfont command changes the data in column 1, row 21 through column 8, row 21, to cgtimes, bold, 10 point, centered text.  Note how the font command applies to the incoming data stream, which differs from the text command, which adds additional output to the job.  Font commands therefore work with integer positions, as they modify the character-base data stream as it passes through to the output.

 

cfont 1,21,8,21,cgtimes,bold,10,center      # order #

cfont 10,21,17,21,cgtimes,bold,10,center    # order date

cfont 19,21,24,21,cgtimes,bold,10,center    # cust #

cfont 26,21,28,21,cgtimes,bold,10,left      # sls prs code

cfont 26,22,64,22,cgtimes,bold,10,left      # sls prs name

cfont 30,21,41,21,cgtimes,bold,10,center    # po #

cfont 43,21,55,21,cgtimes,bold,10,center    # ship via

cfont 57,21,64,21,cgtimes,bold,10,center    # ship date

cfont 66,21,80,22,cgtimes,10,center         # terms

 

# detail section

cbox .5,22.5,80.5,56.5,5,crows=24.5::10,ccols=5 10 16 51 55 67

text 1,23,"Qty\nOrd",univers,italic,10,right,cols=4

text 6,23,"Qty\nShip",univers,italic,10,right,cols=4

text 11,23,"Qty\nBkord",univers,10,italic,right,cols=4

text 17,23,"\nItem & Description",univers,italic,10

text 52,23,"\nU/M",univers,italic,10,center,cols=3

text 56,23,"Unit\nPrice",univers,italic,10,right,cols=11

text 68,23,"Extended\nPrice",univers,italic,10,right,cols=12

 

 

This section performs two distinct fonting functions.  First, the detail item columns are fonted.  Note that you can't simply font the entire detail section in a proportional font, as the spacing between columns would be lost.  Instead, each column is fonted individually.
 
However, the data stream for the invoice also contains memo lines in the middle of the detail item lines, and those memo lines should not be broken into individual columns.
 
Therefore, an additional font command is added after the column fonting, which will override any font characteristics defined for any given data position in a prior font command.  This memo section fonting uses a technique that will scan the page for a pattern (in this example, 4 spaces in the region outlined by column 1, row 25 through column 4, row 56), and change font characteristics relative to those locations found.  In this example, wherever the 4 spaces are found, fonting will occur 17 columns to the right, 0 rows down, for 60 columns and 1 row.  These are the memo lines found in the midst of the item detail lines.

 

cfont 1,25,4,56,cgtimes,10,bold,right        # qty ord

cfont 6,25,9,56,cgtimes,10,bold,right        # qty shipped

cfont 11,25,15,56,cgtimes,10,bold,right      # qty b/o

cfont 17,25,50,56,cgtimes,10,left            # item # & desc

cfont 52,25,54,56,cgtimes,10,bold,center     # u/m

cfont 56,25,66,56,cgtimes,10,bold,right      # unit price

cfont 68,25,79,56,cgtimes,10,bold,right      # extended

 

# memo section

font "    @1,25,4,56",17,0,60,1,cgtimes,10,left

 

# footer section

cbox 57,57,80.5,65,crows=59 63,ccols=67::20

text 58,58,"Sales Amt",univers,11

cfont 58,60,66,60,univers,11,left

text 58,61,"Sales Tax",univers,11

text 58,62,"Freight",univers,11

text 58,64.25,"TOTAL",univers,bold,14

cfont 68,58,79,65,cgtimes,bold,right,14                  # totals