PRINTING with
PxPLUS With PxPLUS for
Windows, there are two print devices :
*WINPRT* and *WINDEV*
Both devices use the Windows' spooling system.
With *WINPRT*, the job will be interpreted by the
Windows' print API, and then passed on to the printer driver, building the final
file which is queued up and sent to the printer.
*WINDEV* is a special interface to the Windows
Print spooler which implements a 'PASSTHROUGH' mode allowing you to send escape
sequences directly to a printer.
This provides an interface similar to opening 'LPT1' directly.
Note:
*WINPRT* is your only choice to print 'fonted scalable text',
images, boxes, lines, etc. along with plain text.
*WINDEV* is your only choice to send printer specific
'escape-sequences' along with a text to the printer but will not support any GUI
Mnemonics.
Example 1
OPEN (1) "*WINPRT*
....<snip>....
PRINT (1) 'FONT'(FONT$,int(C*.8)),
PRINT (1) 'TEXT'(@x(X+66.5),@y(Y+.5),@x(X+75),@y(Y+2),FC$),
PRINT (1) 'PEN'(1,4,0),
PRINT (1) 'RECTANGLE'(@x(MX),@y(MY+5),@x(MX+20),@y(MY+7)),
Example 2
OPEN (1) "*WINDEV*"
PRINT (1) 'BO',ESC+"(s12H",'EO', ! HP Laser 12 cpi mode. Do not use 'BO'+ESC....+'EO'
PRINT (1) TXT$
When you open the Windows' spooler with either *WINPRT*
or *WINDEV* you can specify a series of options separated by semi-colons
following *WINxxx* in the path name.
By default, as if you just issue an
OPEN (1) "*WINPRT*"
PxPLUS will pop-up the standard Windows'
printer selection box and let you choose which printer you want to use along
with various properties such as orientation, copies, print to file, etc.. The
printer and properties selected will remain current throughout the rest of the
PxPLUS session.
To force the assignment of a specific printer,
place such printer name following the *WINPRT*, separated by a semi-colon:
OPEN (1) "*WINPRT*;Epson FX-80 on
\\server1\queue1"
This will open an Epson FX-80 printer (as per the
Windows control panel) on \\server1\queue1.
There are also a couple of special queue names: "ASIS"
and "DEFAULT".
"ASIS" will open the printer with exactly the same settings from the prior print
job, and "DEFAULT" opens the printer queue which is currently "set as default".
Neither of these will display the printer selection dialogue.
OPEN (1) "*WINPRT*;ASIS"
To find out the names of all the configured
printers in the system use the directive:
WINPRT_SETUP LIST X$
This will place a list of all configured printers
into X$ (comma separated).
To find the current selected printer:
WINPRT_SETUP READ X$
To change the current selected printer:
WINPRT_SETUP WRITE "Epson FX80 on
\\server1\queue1"
To set printer properties, add the properties
following the printer name, separated by semi-colons such as:
OPEN (1) "*WINPRT*;Epson FX80 on
\\server1\queue1;ORIENTATION=LANDSCAPE;COPIES=3"
or
OPEN (1) "*WINPRT*;;ORIENTATION=LANDSCAPE"
- Note the double semi-colons with the
second statement.
To determine the current selected printer
properties:
WINPRT_SETUP READ PROPERTIES P$
To set the current printer properties:
WINPRT_SETUP WRITE PROPERTIES P$
One of the printer properties is OFFSET.
The OFFSET, if returned, will be in 1/1000" of an inch. However, the margin size
is not something PxPLUS can retrieve. Therefore there may be some variation to
the margins between different printers.
The following command will set a 1/2 inch left
margin and a 3/4 inch top margin:
WINPRT_SETUP WRITE PROPERTIES
"OFFSET=500:750"
This provides pretty accurate x and y coordinates
for the page. In the event that margins shift around in your report, add some
code for different printers in order to move the OFFSET around. Adjusting the
OFFSET can compensate for different margin sizes. OFFSET can be specified with
positive and negative values.
To get the list of available fonts:
OPEN (1) "*WINPRT*" (Printer must be opened
first)
F$= 'FONT' ( LIST *, channel )
PRINT F$ (Prints list of fonts, comma separated)
Find out about the font sizes of a certain font
and check whether this font can be printed by:
S$='FONT' (LIST "Arial" ,channel)
From this list of font sizes, set the default
font with:
PRINT (channel) 'FONT'(<font name>,<font
size>),'DF',
PRINT (channel) 'FONT'("Arial",-10),'DF',
Be aware of the negative size value.
A negative size means: use that point size
A positive size means: use this factor relative to the default size.
PRINT (channel) 'FONT'("Arial",0.75),'DF',
With this option, the font size can be increased
or decreased and increases or decreases the number of print positions.
PRINT (channel) 'FONT'("Arial",mxc(channel)/<positions_required>),'DF',
Be careful with the point sizes of the fonts.
Rounding to the nearest "supported" point size will occur. For example: If you
specify a point size of 1.5, Windows will round this to a size it supports. The
print driver will also influence the point size rounding.
MXC() and MXL() return different values when a
default font size from different printers has been forced.
The values will vary from one printer to the
next. It will vary based upon the supported fonts or font sizes for the printer
driver, as well as the margins and offsets currently set for the driver. It will
also vary based upon the paper size and orientation (landscape vs portrait) for
that printer. We have never seen the exact same col/row values yet when
switching between different printers/printer drivers. This is why we recommend
that the logic should dynamically adjust the size, until you get the minimum
number of cols/rows, required for the report. However your report may vary
slightly in size during output.
A lot of such instructions are implemented in our
sample program "fontpick".
Windows will add a form feed to the end of a job,
whether you send it through *WINPRT* or through *WINDEV*. Therefore, whenever
you close the printer, the job will end, and a form feed is produced.
To print directly to the printer, open 'LPT1'
directly. However, we advise to use an UNC (Universal Naming Convention):
OPEN (1)"\\server_name\printer_name"
If PRINT causes an error 13, add a LOCK(1) to
your code right after the OPEN.
To make your report look the same on every
printer, the two mnemonics 'CPI'() and 'LPI'() can be of help.
Add a number (per inch) to force the @X() @Y() locations to be more exact and
independent from the selected default font.
For example:
OPEN(1)"*WINPRT*"
PRINT (1)'FONT'("Courier New",-10),'df',
PRINT (1)'CPI'(10),'LPI'(6),
The first print statement forces the printer to a
specific font, and recalculates the number of columns and rows the print driver
will support per page for this printer.
The second print line forces 10 characters to the
inch, and 6 lines to the inch. This does NOT change the default font, but it
changes PxPLUS internal calculations of the column and row to real pixel
coordinates. In this example, a print @x(0) would be up against the left margin
of the page, while @x(10) would be exactly 1 inch from the left margin, @x(20)
would be 2 inches from the left margin and so on. The same applies to @y() in
relation to the 'LPI'().
However, the coordinates determine the printable
area of the page. Therefore the differences from one print driver to the next
can have an impact on margins and offsets.
Questions & Answers
Q: When printing with "*winprt*" is there a way
to abort the printing by an instruction and remove the current print job from
the print spooler?
A: Adding an 'AB' mnemonic to the *WINPRT*
channel will abort the current document while
Q: In Windows, how do I determine which printer
is set as the current printer?
A: You could do something like:
WINPRT_SETUP READ A$
and A$ will contain the name of the open
current printer.
Q: In Windows, how do I determine which printer
is set as the default printer?
A: Windows stores the Default Printer in the
WIN.INI file. To find out what it is, you can use the *INIFILE Utility to read
this value:
CALL "*INIFILE;READ","WIN.INI","Windows","Device","",default_prt$,80
PRINT default_prt$
Q: How can I access local printers from a WindX
Workstation?
A: To access a Printer on the local WindX PC,
insert "[WDX]" in front of the Print Name.
For example:
OPEN (1)"[WDX]*WINPRT*"
or OPEN (1)"[WDX]*WINDEV*"
or OPEN (1)"[WDX]LPT1"
Q: How do I know when I am in WindX so I can
print to local printers ?
A: We recommend that you set a global variable if
WindX is running. Add a line like this to your startup program:
IF MID(MSE,22,1)>$00$ AND MID(MSE,22,1)<$FF$
THEN %WDX$="[WDX]"
Then, where you open the printer, add:
OPEN(CHAN)%WDX$+"*WINPRT*"
The %WDX$ variable will get a value only when
running WindX, if not the variable will be empty.
Q: How can I open and close the printer without
printing a 'Form Feed' ?
A: OPEN INPUT (chn) "*WINPRT*"
This will allow you to open the printer but not
start any document. In fact, it simply tests whether the printer is present and
determines which fonts are available using the 'FONT'(LIST *,chn) function.
The INPUT clause indicates that the printer is in 'Query' mode only. After all,
it is hard to print to an input only device.
Q: How can I 'right justify' columns ?
A: The 'JR' and 'JD' mnemonics work with fixed
length outputs. Which means, when sending numeric data, the output is formatted
using a consistent format mask.
'JR' takes the length of the following string and
determines whether the end-point is based upon fixed length printed output. Just
like printing 10 characters at 10 CPI, the printed width must be right justified
within one inch. Once the length of the field is determined and the end point is
computed, PxPLUS subtracts the true length of the printed text based upon the
proportional font chosen to determine the start point for the text. The result
is right justified output assuming all the fields are the same length.
'JD' is a variation thereof and is based upon
numeric output. Instead of computing the end-point it computes the location of
either the last digit or the decimal point. For example if you print 1234.56
with the format mask (###,##0.00), PxPLUS computes the location of the decimal
point. PxPLUS takes the number of characters in front of that point (8 in the
above example) and multiplies the logical CPI resulting in 8/10ths of an inch.
PxPLUS , then subtracts the actual size of the first eight characters from the
output as per the proportional font selected and uses this as the start point
for printing the complete output. The net result is that the final digit and/or
decimal point will always be aligned in the same position assuming a consistent
format mask. A trailing sign, ')', 'CR', or 'DB' will not effect the alignment.
It is important to remember that with both the
'JR' and 'JD' mnemonics, the output must always be the same length, that is,
numeric data MUST be printed using a format specification.
Please note that a standard PRINT (channel) <num_value>:"##,##0.00",
without any justification, will always be formatted with the 'JL' mnemonic.
Also remember .....
PxPLUS prints with two different printing
planes. One for Text and one for Graphics. Fonted text is printed on the
graphics plane. The graphic plane lays on top of the text plane.
The one exception to this is the 'FONT'()
followed by a 'DF', which sets the font height and width of the characters
printed on the text plane. All plain print commands will then use this text font
and size on the text plane until you issue another 'FONT'() followed by a 'DF'.
This of course, re-adjusts the character size of the text plane.
Remember also that the X and Y coordinates for
each column and row are based upon the cell size of the text plane.
All other 'FONT' () commands affect the graphics
plane. To place text on the page in the graphics plane, you need to use a
'TEXT'() mnemonic. A regular print command with no 'TEXT'() mnemonic places text
on the text plane.
A common way to print is to open the printer.
Print a 'FONT'() which has a specific point size (negative size value) and a
'DF'. Then you can print around the page on the graphics plane, printing
'FONT'() and 'TEXT'() mnemonics to get your differe
|