PreviousNext
Help > Programming with LAUNCHER Office > LNCCMD commands > Commands list > SETPRINTER command
SETPRINTER command

 
This command allows the AS/400 program to:

         Change some properties of the designated printer.

         Configure a Windows printer with a previously saved configuration.

         Redirect the output of the printer to a file.

         Change the default printer.

 

Calling RSTPRINTER Command Cancels Changes Made by SETPRINTER 

 

Syntax

 

CHGVAR

VAR(&CMD) VALUE('SETPRINTER')

CHGVAR

VAR(&PARM1) VALUE('Printer="Printer name"
[ ; setdefault
= True/False ]
[ ; prnfile="Path to output file" ]
[ ; configfile="Path to configuration file" ]
[ ; trunc= True/False ]
[ ; Source=Value ]
[ ; Orientation=Value ]
[ ; Duplex=Value ]
[ ; Copies=Value ]
')

 

 

CALL

PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 &RESULT)

 

 

Parameters

 

Parameters

 

Parm1

Printer = Printer name. Use the name known from the Windows system.

 

Setdefault = True/False. True : makes the printer as default printer.

 

Prnfile = Full path to the output file to be generated.

Do not use this option in a Windows TSE or CITRIX environment.

 

Configfile = Full path to the printer configuration file.
This configuration file was previously generated by the :
Printer configuration file.

 

Trunc = True/False

True : The Prnfile is cleared.

False : The new data will be append to the PrnFile.

 

Orientation

Portrait = 1

Landscape = 2

 

Source

First = 1

Upper = 1

Onlyone = 1

Lower = 2

Middle = 3

Manual = 4

Envelope = 5

Envmanual = 6

Auto = 7

Tractor = 8

SmallFMT = 9

LargeFMT = 10

LargeCapacity = 11

Cassette = 14

FormSource = 15

Last = 15

 

Copies

Copies number to print.

 

Duplex

Simplex = 1

Vertical = 2

Horizontal = 3

 

 

Notes

- This command allows you to temporarily switch to a printer configuration that you have pre-registered in a file.

 - When printing a mail merge, print to a file.

This speeds up the execution of mass mailings with a large amount of registration and helps bypass some Word bugs.

Notably the problems of Word with files taking up too much space in memory.

Printing in a file always concatenates the new data with the data already present in the file.

The Trunc option is used to empty the file when calling the SETPRINTER command. If multiple impressions are made, before calling RSTPRINTER, the data will be concatenated.

For example, you can redirect the output of the printer to a file (PRN file). Using the LAUNCHER IFSPUT command and the CL LNCPRTDOC command, you can move the PRN file to an AS400 ASQ.

Be careful, the use of printing in a file in TSE mode is strongly discouraged. 

 

Example

This example prints the result of a Word mail merge into a text file (.PRN).

 

//Connect to LAUNCHER server

LNCOPEN

//Send the datasource to the PC

LNCXFER PCFILE('%LNCDIR%\samples\sp_cust.txt') FROMFILE(SP_CUST) CLOSECOM(*NO)

//Change the printer configuration

LNCCMD CMD(SETPRINTER) PARM1('printer="HP LaserJet 1200 Series PCL 6";prnfile="%lncdir%\samples\test.prn";trunc=true;setdefault=true')

//Open Word and merge template and data

LNCCMD CMD(WORDOPEN)

LNCCMD CMD(WMAILMERGE) PARM1('document="%lncdir%\samples\sp_cust.doc"+

;destination=wdSendToPrinter;DataSource="%lncdir%\samples\sp_cust.txt"')

//Restore printer configuration

LNCCMD CMD(RSTPRINTER) PARM1('printer="HP LaserJet 1200 Series PCL 6"')

 

Voir aussi

 

RSTPRINTER

WMAILMERGE