image\bbj40.gif Printing in BBj


BBj-Specific Information

For this topic's original documentation, see the SYSPRINT Printing.

Important Notes

 

MODE="CLIENT"

Provided for backwards compatibility. This is the default behavior for SYSPRINT devices, and not a required mode. See MODE="SERVER."

MODE="SERVER"

Selects server-side printing. If this mode is omitted the printer is assumed to be on the client for a SYSPRINT device.

MODE="TMARGIN=inches"

Sets the initial value of the top margin in inches. For example TMARGIN=0.5 sets a top margin of ½ inch.

MODE="LMARGIN=inches"

Sets the initial value of the left margin in inches.

MODE="RMARGIN=inches"

Sets the initial value of the right margin in inches.

MODE="BMARGIN=inches"

Sets the initial value of the bottom margin in inches.

MODE="PORTRAIT"

Sets the default paper orientation to portrait mode.

MODE="LANDSCAPE"

Sets the default paper orientation to landscape mode.

MODE="HEIGHT=inches,WIDTH=inches"

Sets the default paper size to the specified width and height.

For example, HEIGHT=11.69,WIDTH=8.27 selects A4 paper.

The following modes are available in BBj 2.01 and higher and only with Java 1.4 or higher:

MODE="TEXT"

Allows users to print their own control codes. Use MODE=TEXT with BO and EO for a SYSPRINT device. When using SYSPRINT without MODE=TEXT, user text is filtered through Java handling of printer control codes, preventing users from sending their control codes to the printer.

MODE="PAPER=type"

Selects the default paper type. For a listing of options, see Available Paper Types.

The following modes are available in BBj 2.04 and higher:

MODE="KEEP_OPEN"

When used with the PREVIEW mode, causes the print preview window to remain open after printing.

MODE="CLIENTEXEC"

When used with the EXECON or EXECOFF modes, this mode causes the command to be executed on the client.

The following mode is available in BBj 4.0 and higher:

MODE="MONOSPACE"

Spaces every character equally on a line, regardless of font type.

The following modes are available in BBj 5.0 and higher:

MAXIMIZE=

Sets the initial print preview to "maximize."

STYLE=

Any of WIDTH, HEIGHT, or TWO. Causes the preview device to fit a page by width or by height, or display two pages, respectively.

ZOOM=

Specifies the print preview zoom. The default is 1.0 for normal view. Set 2.0 for double size, .5 for half size, etc.

The following mode is available in BBj 7.0 and higher:

MODAL

Causes print preview to behave as a modal dialog

The following mode is available in BBj 8.0 and higher:

MODE="O_CREATE"

Creates the file if it does not exist

Adjust the margins on a page-by-page basis using these mnemonics:

'TMARGIN' (inches), 'LMARGIN' (inches), 'RMARGIN' (inches) and 'BMARGIN'(inches).

To select a particular printer by name, enter that printer's name in the description field of the alias (when using SYSPRINT in BBj 2.01 and higher and Java 1.4 and higher).


SLAVE Alias

In order to print slave printing through the BBj TermConsole, there should be one or more special ALIAS lines in your config.bbx file, associating a device alias with the pseudo-device SLAVE. Below is a simple example of an ALIAS line for printing with a slave printer.

ALIAS PD SLAVE "SLAVE Printer" SLON=5B5B,SLOFF=5D5D

This printer alias will slave print to the BBj TermConsole of whichever interpreter opens the printer.

 

SYSPRINT Batching

Print batching allows the program to buffer writes to the print channel on the server side until the print channel is closed, or until batching is ended. When batching has ended, all prints up until that point will be sent to the client side in one message. This is recommended for thin client implementations and for large print jobs.

Batching can be set up in one of two ways:

1. Include the BATCH mode in the printer modes (either through the config.bbx alias or through the OPEN Verb). There are two options to BATCH mode; END and FF.

The END option will buffer the writes until the print channel is closed with the CLOSE Verb, END, or the ENDSPOOL mnemonic.

The FF option will buffer the writes until an ‘FF’ mnemonic is written, and then it will send the batched writes to the client side. It will also send the writes when the print channel is closed. The FF option is useful for very large print jobs so that the buffer on the server side does not get too large. It will send the print job page by page. Add the mode "BATCH" to get batching by default:

If setting mode in config.bbx alias:

ALIAS LP SYSPRINT "" BATCH=END

or

ALIAS LP SYSPRINT "" BATCH=FF

If setting mode in OPEN verb:

OPEN (SYSPRINT,MODE="BATCH=END")"LP"

or

OPEN(SYSPRINT,MODE="BATCH=FF")"LP"

2. Use the mnemonics 'STARTBATCH' Mnemonic and 'ENDBATCH' Mnemonic. These are dynamic and can be set at any time once the print channel is opened, with or without the BATCH mode being set. If the 'STARTBATCH' mnemonic is used, prints will be stored on the server side until the 'ENDBATCH' (or 'ENDSPOOL') mnemonic or the CLOSE verb.

SYSPRINT=UNT
OPEN(SYSPRINT)"LP"
PRINT(SYSPRINT)'STARTBATCH'
PRINT(SYSPRINT)"batch printing"
PRINT(SYSPRINT)"another line"
PRINT(SYSPRINT)'ENDBATCH'
CLOSE(SYSPRINT)

Errors during batching

If BATCH=END mode is used but the 'ENDBATCH' mnemonic is not printed before the CLOSE verb, and there is an error in the prints that were batched, the error will not be reported unless an ERR= branch is set in the CLOSE verb. Errors can be reported by calling 'ENDBATCH' before the CLOSE or by using the ERR= branch in the CLOSE. If there is an error during batch mode, all prints up until that point will be printed to the printer or preview when the print channel is closed if 'ENDBATCH' is not used. If the program will not throw errors in the prints, it is safe to set the BATCH mode without using the ERR= branch in the CLOSE.

If BATCH=FF mode is used then errors will be reported at the ‘FF’ mnemonic. If an error occurs and the print channel is closed before an ‘FF’ or ‘ENDBATCH’ mnemonic, then errors will not be reported unless the CLOSE verb has an ERR= branch.

Batching examples

REM Batching using mode in config and not setting ERR= in CLOSE.
REM Your alias to "LP" must have the mode BATCH=END in it.
REM Use this if you don't expect
REM errors in your code and you don't want to change your code.
LET SYSPRINT = UNT
OPEN (SYSPRINT,MODE="PREVIEW,COLS=80,ROWS=62")"LP"
PRINT(SYSPRINT)"printing a line"
PRINT(SYSPRINT)"printing another line"
CLOSE(SYSPRINT)
END
-----------------------
REM Batching using mode and catching error in CLOSE
LET SYSPRINT = UNT
OPEN (SYSPRINT,MODE="BATCH=END,PREVIEW,COLS=80,ROWS=62")"LP"
PRINT(SYSPRINT)"printing a line"
PRINT(SYSPRINT)"printing another line"; REM print @100 to cause error
CLOSE(SYSPRINT,ERR=PRINTERR)
END
PRINTERR:
PRINT "error on print"
END
-----------------------
REM Batching using mode and catching error with 'ENDBATCH'
LET SYSPRINT = UNT
OPEN (SYSPRINT,MODE="BATCH=FF,PREVIEW,COLS=80,ROWS=62")"LP"
PRINT(SYSPRINT)"printing a line"
PRINT(SYSPRINT)"printing another line"; REM print @100 to cause error
PRINT(SYSPRINT)'ENDBATCH'
CLOSE(SYSPRINT)
END
-------------------------
REM Batching using 'STARTBATCH' and ERR= in CLOSE
LET SYSPRINT = UNT
OPEN (SYSPRINT,MODE="PREVIEW,COLS=80,ROWS=62")"LP"
PRINT(SYSPRINT)'STARTBATCH'
PRINT(SYSPRINT)"printing a line"
PRINT(SYSPRINT)"printing another line"; REM print @100 to cause error
CLOSE(SYSPRINT,ERR=PRINTERR)
END
PRINTERR:
PRINT "error on print"
END
--------------------------
REM Batching using 'STARTBATCH' and 'ENDBATCH'
LET SYSPRINT = UNT
OPEN (SYSPRINT,MODE="PREVIEW,COLS=80,ROWS=62")"LP"
PRINT(SYSPRINT)'STARTBATCH'
PRINT(SYSPRINT)"printing a line"
PRINT(SYSPRINT)"printing another line"; REM print @100 to cause error
PRINT(SYSPRINT)'ENDBATCH'
CLOSE(SYSPRINT)
END
--------------------------
REM Combination of MODE, 'STARTBATCH' and 'ENDBATCH'
LET SYSPRINT = UNT
OPEN (SYSPRINT,MODE="BATCH,PREVIEW,COLS=80,ROWS=62")"LP"
PRINT(SYSPRINT)"printing a line"
PRINT(SYSPRINT)"printing another line"; REM print @100 to cause error
PRINT(SYSPRINT)'ENDBATCH'
PRINT(SYSPRINT)"printing a line I don't want batched for whatever reason"
PRINT(SYSPRINT)'STARTBATCH'
PRINT(SYSPRINT)"printing more batched lines"
PRINT(SYSPRINT)"and more.."
PRINT(SYSPRINT)'ENDBATCH'; REM Ending batching
CLOSE(SYSPRINT)
END
-------------------
REM Batching using the FF option
LET SYSPRINT = UNT
OPEN (SYSPRINT,MODE="BATCH=FF,PREVIEW,COLS=80,ROWS=62")"LP"
PRINT(SYSPRINT)"printing a line"
PRINT(SYSPRINT)"printing another line"; REM print @100 to cause error
PRINT(SYSPRINT)'FF’; REM will send batch so far
PRINT(SYSPRINT)"printing a line on page 2 "
PRINT(SYSPRINT)"printing more batched lines"
PRINT(SYSPRINT)"and more.."
CLOSE(SYSPRINT,ERR=ERRONPRINT)
END
ERRONPRINT:
PRINT "Error on print"
END

See Also

Printing Functionality and Performance

Print Preview - GUI

SYSPRINT Printing