Below is a simple text stream with no enhancements, as displayed in the UnForm design tool's preview window.
It is a single page of text, but it has 2 logical 10-line pages, like a
two-up label. What we want to end up with is separate graphical formatting for
each page. And we would prefer to do this without having to put a lot of code in
a code-block.
Page 1 has a name, address and
contact, and page 2 has an account balance. To simplify matters, a programmer
has put a page type number at the top of each page, which can be used to detect
which page-type we're dealing with.
In the "real world" we might be using the position of some other data element
to detect the page-type being processed, but both use the UnForm get
function in the same way.
Our first version of a ruleset to enhance this document is shown below.
In a prepage code-block it reads the page-type number value into a variable, and then in the main
section erases and reformats the page-type number with text, erases the dashed
separator line, and draws a box around the text after moving all the text over
one column.
Also notice the "page 10" command which sets the page boundary at
10 lines. We've created this text file to simplify this sample. There is nothing
about the fact that this sample has logical 10-line pages without a form-feed that
matters related to dealing with multi-format documents.
The resulting version 1 enhanced form is below:
But notice that page-type 2 below does not look formatted properly with the larger box
around a single line.
So page-type 2 needs different formatting.
This is a 3-step ruleset change process:
- Change COPIES 1 to PCOPIES 2.
("pcopies" functions a page at a time, while "copies" waits for the whole
job to be completed before producing a copy)
- Add a PRECOPY block with copy SKIP logic based on the page-type.
- Add separate IF COPY .. END IF command sections with separate formatting for the
different page-types
In the above ruleset, pay particular attention to the fact that the SKIP is not
in the form of a command, but is what is known as a "boolean" variable that gets
set to a value of 1 to indicate that a skip should be performed. The SKIP
variable is reset to zero automatically by UnForm for every page and copy, which
is the same as saying "do not skip".
Also notice that the IF COPY command section must be closed out with an END
IF command.
The resulting enhanced form now has a more properly formatted look for
page-type 2.
In the above example the second "copy" was really a different format for a second
page, and not actually a duplicate copy of a page.
Some more common applications for using UnForm's multi-copy logic are
described briefly below.
Sometimes the second copy is an image attachment, like a legal terms and
conditions page. In this case the NOTEXT keyword would be added to the IF
COPY block for COPY 2, along with an ATTACH command, instead of the
different graphical enhancements.
The DUPLEX command can be added to COPY 1 to prevent ejection of the
page so that a file attachment will print on the reverse side of a page.
Other times the second copy may be an exact duplicate of the page going to a
different output device, like an accounting department printer or fax machine,
or a different printer tray. In the first case the OUTPUT command would be
issued with a different operating system device command. In the second case the TRAY
command would be issued to change
the tray number.
Many UnForm commands and keywords have counterparts which are variables that can
be set inside of a code-block. The reference table below shows which ones.
The ability to reference these commands or keywords as variables can give a
developer more finer control over the conditions which must be met to trigger
the particular command or keyword action, as was seen with the skip variable in
the main example.
Reference Table
Below is a Reference Table of where to find multi-format page related topics
in the UnForm PDF manual.
UnForm Keywords or Commands: |
v 6.0
manual |
v 7.0
manual |
attach |
56 |
90 |
copies, pcopies |
77 |
113 |
duplex |
86 |
122 |
if copy .. end if |
97 |
133 |
notext |
115 |
156 |
output |
117 |
158 |
precopy |
121 |
162 |
tray |
137 |
179 |
|
|
|
Code-Block Variables: |
|
|
copies, pcopies |
190 |
235 |
copy |
190 |
235 |
duplex$ |
190 |
235 |
output$ |
191 |
236 |
tray$ |
191 |
236 |
skip |
191 |
236 |