Printing in BBj
BBj-Specific Information
For this topic's original documentation, see SYSPRINT Printing.
Important Notes
-
MODE="FORM" is not available in BBj. It is Novell specific.
-
Unless the MODE=SERVER is specified when opening a printer on a channel, BBj only has access to the client workstation's printers. Everything is client-based until otherwise specified via the SERVER mode.
-
In Windows, the list of available printers depends upon the user that BBjServices is started with. For example, if BBjServices is started as the administrator user and this user does not have any printers defined, then any BBj interpreter session that attempts to access a non-client SYSPRINTer will not be successful because there are no defined printers for this account.
-
Server side printing in UNIX requires an X server to be running. When using a remote printer, the remote machine must have a graphics environment, such as X, but the server does not.
-
Opening an LPT port on Microsoft Vista requires the O_CREATE mode
-
Opening a device (including printers) via client mode using a Thin Client requires the O_CREATE Mode
The BUI and DWC browser write SYSPRINT output to a PDF document, which can be delivered to the CLIENT in a new browser tab, or to a specified SERVER file. If the PDF is delivered to the CLIENT, the optional FILE mode defines the default file name to be used if the user downloads the PDF file.
Example
|
SYSPRINT Arguments
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 1/2 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. This mode is unavailable in PREVIEW mode. |
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. |
MODE="MONOSPACE" |
Spaces every character equally on a line, regardless of font type. |
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. |
Causes print preview to behave as a modal dialog. |
|
Creates the file if it does not exist. |
|
The following modes are available in BBj 10.0 and higher: |
|
|
Generate a PDF instead of sending output to the printer. |
FILE= |
(With PDF) send PDF output to specified file. |
The following modes are available in BBj 11.0 and higher: |
|
NATIVE |
Use the operating system print dialog, rather than the Java cross-platform dialog. The native dialog is usually faster and offers more features to users. The native dialog is not available when opening the channel, it will be displayed on close, or when the user attempts to print, in print preview. |
A blank password disables security on the document. |
|
PDFPASS=password |
Password to allow editing of generated file. |
The following mode is available in BBj 12.0 and higher: |
|
OPENPDFPASS=password |
Password to restrict opening of the file. |
The following mode is available in BBj 17.0 and higher: |
|
NOSAVEAS |
Disable the PREVIEW "Save As" menu item. |
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"
-
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