Previous Topic Next topic Print topic


PC_PRINTER_INFO

Returns a native device context handle, and other information that can be used to enhance the printing of a document by calling native graphics functions directly.
Restriction: This routine is not currently supported on UNIX platforms.

Syntax:

call "PC_PRINTER_INFO using     cblt-pi-printer-handle
                                cblt-pi-printer-info-struct
                      returning status-code

Parameters:

cblt-pi-printer-handle
Using call prototype (see Library Routines - Key) : cblt-x4-comp5
Picture: pic x(4) comp-5.
cblt-pi-printer-info-struct
Group containing
01 print-info-struct  
  03 cblt-pi-struct-size               cblt-os-size   *> pic x(4) comp-5 or pic x(8) comp-5 (64-bit native only). 
  03 cblt-pi-printer-hdc               cblt-pointer   *> pointer. 
  03 cblt-pi-printer-hps               cblt-os-size   *> pic x(4) comp-5 or pic x(8) comp-5 (64-bit native only). 
  03 cblt-pi-printer-orientation       cblt-x4-comp5  *> pic x(4) comp-5. 
  03 cblt-pi-printer-rows              cblt-x4-comp5  *> pic x(4) comp-5. 
  03 cblt-pi-printer-cols              cblt-x4-comp5  *> pic x(4) comp-5. 
  03 cblt-pi-printer-rows-left         cblt-x4-comp5  *> pic x(4) comp-5. 
  03 cblt-pi-printer-max-horiz         cblt-x4-comp5  *> pic x(4) comp-5. 
  03 cblt-pi-printer-max-vert          cblt-x4-comp5  *> pic x(4) comp-5. 
  03 cblt-pi-printer-min-horiz         cblt-x4-comp5  *> pic x(4) comp-5. 
  03 cblt-pi-printer-min-vert          cblt-x4-comp5  *> pic x(4) comp-5. 
  03 cblt-pi-printer-curr-horiz        cblt-x4-comp5  *> pic x(4) comp-5. 
  03 cblt-pi-printer-curr-vert         cblt-x4-comp5  *> pic x(4) comp-5. 
  03 cblt-pi-printer-copies            cblt-x2-comp5  *> pic 9(4) comp-5. 
  03 cblt-pi-printer-quality           cblt-x2-comp5  *> pic 9(4) comp-5. 
  03 cblt-pi-printer-color             cblt-x1-comp5  *> pic 99 comp-5. 
  03 cblt-pi-reserved-item1            cblt-x1-comp5  *> pic 99 comp-5. 
  03 cblt-pi-printer-device-ver        cblt-x2-comp5  *> pic 9(4) comp-5. 
  03 cblt-pi-printer-name 
    05 cblt-pi-printer-pname-size      cblt-os-size   *> pic x(4) comp-5 or pic x(8) comp-5 (64-bit native only).  
    05 cblt-pi-printer-pname           cblt-pointer   *> pointer. 
  03 cblt-pi-printer-type  
    05 cblt-pi-printer-ptype-size      cblt-os-size   *> pic x(4) comp-5 or pic x(8) comp-5 (64-bit native only). 
    05 cblt-pi-printer-ptype           cblt-pointer   *> pointer. 
  03 cblt-pi-printer-device   
    05 cblt-pi-printer-pdevice-size    cblt-os-size   *> pic x(4) comp-5 or pic x(8) comp-5 (64-bit native only).  
    05 cblt-pi-printer-pdevice         cblt-pointer   *> pointer. 
  03 cblt-pi-printer-location    
    05 cblt-pi-printer-plocation-size  cblt-os-size   *> pic x(4) comp-5 or	pic x(8) comp-5 (64-bit native only). 
    05 cblt-pi-printer-plocation       cblt-pointer   *> pointer. 
  03 p-comment
    05 cblt-pi-printer-pcomment-size   cblt-os-size   *> pic x(4) comp-5 or pic x(8) comp-5 (64-bit native only).  
    05 cblt-pi-printer-pcomment        cblt-pointer   *> pointer. 
  03 cblt-pi-printer-type   
    05 cblt-pi-printer-papersize-size  cblt-os-size   *> pic x(4) comp-5 or pic x(8) comp-5 (64-bit native only). 
    05 cblt-pi-printer-papersize       cblt-pointer   *> pointer. 
status-code
See Library Routines - Key

On Entry:

printer-handle
The printer handle returned when the printer was opened
cblt-pi-struct-size
The size of the structure
cblt-pi-printer-papersize
The size of the associated buffers
cblt-pi-printer-pcomment
The address of the buffer

On Exit:

cblt-pi-printer-hdc
Handle to the printer device context
cblt-pi-printer-hps
Reserved
cblt-pi-printer-orientation
Orientation of the printed output:
1 portrait
2 landscape
cblt-pi-printer-cols
Total number of columns on a page in the current font
cblt-pi-printer-rows_left
Number of rows left on the current page in the current font
cblt-pi-printer-max-horiz
Maximum value of graphics coordinate available in the horizontal axis
cblt-pi-printer-max-vert
Maximum value of graphics coordinate available in the vertical axis
cblt-pi-printer-min-horiz
Minimum value of graphics coordinate available in the horizontal axis
cblt-pi-printer-min-vert
Minimum value of graphics coordinate available in the vertical axis
cblt-pi-printer-curr-horiz
Current graphics X coordinate
cblt-pi-printer-curr-vert
Current graphics Y coordinate
cblt-pi-printer-copies
Number of copies
cblt-pi-printer-quality
The quality the printer is set to. Can be one of:
0 Draft
1 Low
2 Medium
3 High
4 Printer's default
Otherwise the DPI is returned.
cblt-pi-printer-color
Color capabilities of the printer:
0 Monochrome
1 Color
cblt-pi-printer-version
Version number of the printer driver
cblt-pi-printer-pname-size
Size of the printer name
cblt-pi-printer-pname
Pointer to the name of the printer
cblt-pi-printer-ptype-size
Size of the printer type
cblt-pi-printer-ptype
Pointer to the cblt-pi-printer-type
cblt-pi-printer-pdevice-size
Size of the printer device
cblt-pi-printer-pdevice
Pointer to the printer device
cblt-pi-printer-plocation-size
Size of the printer's location
cblt-pi-printer-plocation
Pointer to the location of the printer
cblt-pi-printer-pcomment-size
Size of the printer's comment
cblt-pi-printer-pcomment
Pointer to the printer's comment
cblt-pi-printer-papersize-size
Size of the printer's paper size
cblt-pi-printer-papersize
Pointer to the printer's paper size
status-code
Printer Handling Routines Return Codes

Comments:

cblt-pi-printer-type specifies the type of printer; for example, HP or Canon.

cblt-pi-printer-device specifies the printer device; for example, lpt1:, :file or :com1. This parameter can be set to multiple devices; each device is separated by a comma (for example, lpt1:,lpt2:).

cblt-pi-printer-comment specifies any comment associated with the printer (for example, the printer might have the comment "Printer for accounts" defined for it).

paper-size defines the paper-size; for example, A4, or Letter.

Example:

$set remove(control)
working-storage section.
copy "cbltypes.cpy".
01 PRT-INFO-1 is typedef.
  03 pi-struct-size      cblt-os-size.
  03 hdc                 cblt-pointer.
  03 hps                 cblt-os-size.
  03 orientation         pic x(4) comp-5.
  03 rows                pic x(4) comp-5.
  03 cols                pic x(4) comp-5.
  03 rows-left           pic x(4) comp-5.
  03 max-horiz           pic x(4) comp-5.
  03 max-vert            pic x(4) comp-5.
 03 min-horiz           pic x(4) comp-5.
  03 min-vert            pic x(4) comp-5.
  03 curr-horiz          pic x(4) comp-5.
  03 curr-vert           pic x(4) comp-5.
  03 copies              pic 9(4) comp-5.
  03 quality             pic 9(4) comp-5.
  03 color               pic 99 comp-5.
  03 reserved1           pic x comp-5.
  03 driver-ver          pic 9(4) comp-5.
  03 pname.
    05 cbsize            cblt-os-size.
    05 buffer            pointer.
  03 ptype.
    05 cbsize            cblt-os-size.
    05 buffer            pointer.
  03 pdevice.
    05 cbsize            cblt-os-size.
    05 buffer            pointer.
  03 plocation.
    05 cbsize            cblt-os-size.
    05 buffer            pointer.
  03 pcomment.
    05 cbsize            cblt-os-size.
    05 buffer            pointer.
  03 ppapersize.
    05 cbsize            cblt-os-size.
    05 buffer            pointer.
01.
  03 document-title.
    05 title-len         pic x(2) comp-5.
    05 title-text        pic x(20).
      03  font-family.
    05 font-family-namelen  pic x(2) comp-5 value 80.
    05 font-family-name     pic x(80).
  03 print-info          PRT-INFO-1.
  03 abort               pic x(4) comp-5 value 1.
  03 control             pic x(4) comp-5 value 2.
  03 flags               pic x(4) comp-5 value 3.
  03 handle              pic x(4) comp-5.
01 cblt-pi-printer-name          pic x(255).
01 cblt-pi-printer-type          pic x(255).
01 cblt-pi-printer-device        pic x(255).
01 cblt-pi-printer-location      pic x(255).
01 cblt-pi-printer-comment       pic x(255).
01 cblt-pi-printer-papersize     pic x(255).

procedure division.
    move 17 to title-len
    move "Printer Info Test" to title-text

    call "PC_PRINTER_OPEN" using by reference handle
                                 by reference document-title
                                 by value flags
                                 by value 0
    end-call

    if return-code = zero
        move all x"0" to print-info
        move length of print-info to pi-struct-size
        set buffer of pname of print-info
            to address of cblt-pi-printer-name
        move 255 to cbsize of pname of print-info
        set buffer of ptype of print-info
            to address of cblt-pi-printer-type
        move 255 to cbsize of ptype of print-info
        set buffer of pdevice of print-info
             to address of cblt-pi-printer-device
        move 255 to cbsize of pdevice of print-info
        set buffer of plocation of print-info
            to address of cblt-pi-printer-location
        move 255 to cbsize of plocation of print-info
        set buffer of pcomment of print-info
            to address of cblt-pi-printer-comment
        move 255 to cbsize of pcomment of print-info
        set buffer of ppapersize of print-info
            to address of cblt-pi-printer-papersize
        move 255 to cbsize of ppapersize of print-info
        call "PC_PRINTER_INFO" using by reference handle
                                     by reference print-info
        end-call
        display return-code
        if return-code not equal zero
            display "PC_PRINTER_INFO failed (return-code)"
            display "   === " return-code
            perform close-down-printer
            stop run
        end-if
        display "Orientation   : " orientation of print-info
        display "Rows          : " rows of print-info
        display "Cols          : " cols of print-info
        display "Rows Left     : " rows-left of print-info
        display "Max horz      : " max-horiz of print-info
        display "Max vert      : " max-vert of print-info
        display "Min horz      : " min-horiz of print-info
        display "Min vert      : " min-vert of print-info
        display "Current horz  : " curr-horiz of print-info
        display "Current vert  : " min-vert of print-info
        display "Copies        : " copies of print-info
        display "Quality       : " no advancing
        evaluate quality of print-info
         when 0 display "Draft"
         when 1 display "Low"
         when 2 display "Medium"
         when 3 display "High"
         when 4 display "printers default used"
         when other display quality of print-info " DPI"
        end-evaluate
        display "Color         : " no advancing
        if color of print-info equals 0
            display "Mono Chrome"
        else
            display "Color"
        end-if
        if cbsize of pname of print-info equal 0
            display "Printer name  : not available"
        else
            display "Printer name  : "
                    cblt-pi-printer-name(1:
                         cbsize of pname of print-info)
           display "Printer name  size : "
                   cbsize of pname of print-info
        end-if
        if cbsize of ptype of print-info equal 0
           display "Printer type  : not available"
        else
            display "Printer type  : "
                    cblt-pi-printer-type(1:
                         cbsize of ptype of print-info)
            display "Printer type size : "
                    cbsize of ptype of print-info
        end-if
        if cbsize of pdevice of print-info equal 0
            display "Printer device: not available"
        else
            display "Printer device(s): "
                    cblt-pi-printer-device(1:
                         cbsize of pdevice of print-info)
            display "Printer device size : "
                    cbsize of pdevice of print-info
        end-if
        if cbsize of plocation of print-info equal 0
            display "Printer location: not available"
        else
            display "Printer location: "
                    cblt-pi-printer-location(1:
                         cbsize of plocation of print-info)
            display "Printer location size : "
                    cbsize of plocation of print-info
        end-if
        if cbsize of pcomment of print-info equal 0
            display "Printer comment: not available"
        else
            display "Printer comment: "
                    cblt-pi-printer-comment(1:
                         cbsize of pcomment of print-info)
            display "Printer comment size : "
                    cbsize of pcomment of print-info
        end-if
        if cbsize of ppapersize of print-info equal 0
            display "Printer papersize: not available"
        else
            display "Printer papersize: "
                    cblt-pi-printer-papersize(1:
                         cbsize of ppapersize of print-info)
            display "Printer papersize size : "
                    cbsize of ppapersize of print-info
        end-if
        display "Driver version : "driver-ver of print-info
    end-if
    perform close-down-printer
    .

close-down-printer section.
    call "PC_PRINTER_CONTROL" using by reference handle
                                    by value abort
    end-call

    call "PC_PRINTER_CLOSE" using by reference handle
    end-call
    .

Previous Topic Next topic Print topic