isCOBOL Evolve : Appendices : Library Routines : WIN$PRINTER : WINPRINT-GET-PRINTER-MEDIA
WINPRINT-GET-PRINTER-MEDIA
The WINPRINT-GET-PRINTER-MEDIA function allows you to access the paper sizes and paper trays supported by the printer.
Syntax
 CALL "WIN$PRINTER" USING WINPRINT-GET-PRINTER-MEDIA
                          WINPRINT-MEDIA
                   GIVING returnCode
Parameters
WINPRINT-GET-PRINTER-MEDIA
Constant
 
WINPRINT-MEDIA
Group Item
Structure defined in isprint.def as follows:
 
01  winprint-media.
    03  winprint-media-printer          pic x(80).
    03  winprint-media-port             pic x(80).
    03  winprint-media-papercount       signed-short.
    03  winprint-media-traycount        signed-short.
    03  winprint-media-paper              signed-short 
                              occurs max-paper-sizes.
    03  winprint-media-trays         signed-short 
                              occurs max-paper-trays.
 
winprint-media-printer
It must be set to the value of WINPRINT-NAME as obtained through a call to WINPRINT-GET-CURRENT-INFO, WINPRINT-GET-CURRENT-INFO-EX, WINPRINT-GET-PRINTER-INFO or WINPRINT-GET-PRINTER-INFO-EX.
winprint-media-port
This parameter is ignored.
winprint-media-papercount
Returns the total number of paper sizes supported by the selected printer driver. This number varies from printer to printer.
winprint-media-traycount
Returns the total number of paper trays supported by the printer driver. This number varies from printer to printer.
Note - this field is not supported under Java 17.
winprint-media-paper
Returns an array of supported paper sizes. The array is limited to a maximum of max-paper-sizes possible sizes. Each number in the array corresponds to a paper size defined by WINPRINT-CURR-PAPERSIZE in isprint.def. The numbers in the array may not appear in sequential order .
winprint-media-trays
Returns an array of supported paper trays. The array is limited to a maximum of max-paper-trays possible trays. Each number in the array corresponds to a paper tray defined by WINPRINT-CURR-TRAY in isprint.def. The numbers in the array may not appear in sequential order .
Note - this field is not supported under Java 17.
Note: The information returned by WINPRINT-GET-PRINTER-MEDIA may be incomplete because Java implements only some of the possible media paper and media tray, in particular the ones defined by the IPP (Internet Printing Protocol). However in the dialog box for the printer selection you could see more formats than the ones isCOBOL is able to handle, because, depending on the OS, special classes are supplied in order to cope with all the formats handled by the OS. So it could happen that, for example, there are four trays available but two of them are identified by the number 0 (unknown), meaning that those two trays are handled only on that operating system.
Return code
returnCode can be any signed numeric data item and provides additional information:
1
Operation successful.
WPRTERR-UNSUPPORTED
The WIN$PRINTER library routine is not supported.
WPRTERR-BAD-ARG
The WIN$PRINTER library routine has been called with bad parameters.