Skip to main content

Problem:

How do you set "Duplex Printing"? (printing on both sides of a page requires optional printer feature)

Resolution:

This will only work for a printer that acutally can print on 2 sides

Manual Duplexing does not work with this method

Using PC_PRINTER_DEFAULT_PROPERTIES.

The PCPDP example program demonstrates how to use the PC_PRINTER_DEFAULT_PROPERTIES routine. The routine requires two parameters, "flags" and "properties".

           call 'PC_PRINTER_DEFAULT_PROPERTIES'

               using by value     flags

                     by reference properties

               returning          status-code

           end-call

The "flags" parameter is an independent, numeric item passed by value. There are eleven predefined initialization values for this parameter, one for each of the printer properties that can be initialized. These values may be combined arithmetically. Combining values permits setting multiple properties with a single function call.

      * PC_PRINTER_DEFAULT_PROPERTIES flags parameter

       77  flags           pic x(4)  comp-5.

      * flags values that determine which properties to update.

      * flags values can be arithmetically combined.

       78  P-PAPERSIZE               value    1.

       78  P-PAPERLENGTH             value    2.

       78  P-PAPERWIDTH              value    4.

       78  P-SCALE                   value    8.

       78  P-COPIES                  value   16.

       78  P-PAPERTRAY               value   32.

       78  P-PRINTQUALITY            value   64.

       78  P-COLOR                   value  128.

       78  P-DUPLEX                  value  256.

       78  P-ORIENTATION             value  512.

       78  P-YRESOLUTION             value 1024.

The "properties" parameter is a data record structure consisting of twelve elementary items. The first item specifies the overall "properties" record length. The other eleven items permit you to specify the options that you want used for the printer properties that you selected with the "flags" setting. The "properties" items that you are not setting should be initialized to NULL values.

      * PC_PRINTER_DEFAULT_PROPERTIES properties parameter

       1   properties.

       2   pr-len          pic x(2)  comp-5.

       2   pr-papersize    pic s9(4) comp-5.

       2   pr-paperlength  pic s9(4) comp-5.

       2   pr-paperwidth   pic s9(4) comp-5.

       2   pr-scale        pic s9(4) comp-5.

       2   pr-copies       pic s9(4) comp-5.

       2   pr-papertray    pic s9(4) comp-5.

       2   pr-printquality pic s9(4) comp-5.

       2   pr-color        pic s9(4) comp-5.

       2   pr-duplex       pic s9(4) comp-5.

       2   pr-orientation  pic s9(4) comp-5.

       2   pr-yresolution  pic s9(4) comp-5.

For each of the "properties" other than "pr-yresolution", there are predefined numeric values that you can select. Specify "dots per inch" as a numeric value for "pr-yresolution" which is the vertical height.

      * pr-papersize settings

       78  DMPAPER-LETTER                 value           1.

       78  DMPAPER-LETTERSMALL            value           2.

       78  DMPAPER-TABLOID                value           3.

       78  DMPAPER-LEDGER                 value           4.

       78  DMPAPER-LEGAL                  value           5.

       78  DMPAPER-STATEMENT              value           6.

       78  DMPAPER-EXECUTIVE              value           7.

       78  DMPAPER-A3                     value           8.

       78  DMPAPER-A4                     value           9.

       78  DMPAPER-A4SMALL                value          10.

       78  DMPAPER-A5                     value          11.

       78  DMPAPER-B4                     value          12.

       78  DMPAPER-B5                     value          13.

       78  DMPAPER-FOLIO                  value          14.

       78  DMPAPER-QUARTO                 value          15.

       78  DMPAPER-10X14                  value          16.

       78  DMPAPER-11X17                  value          17.

       78  DMPAPER-NOTE                   value          18.

       78  DMPAPER-ENV-9                  value          19.

       78  DMPAPER-ENV-10                 value          20.

       78  DMPAPER-ENV-11                 value          21.

       78  DMPAPER-ENV-12                 value          22.

       78  DMPAPER-ENV-14                 value          23.

       78  DMPAPER-CSHEET                 value          24.

       78  DMPAPER-DSHEET                 value          25.

       78  DMPAPER-ESHEET                 value          26.

       78  DMPAPER-ENV-DL                 value          27.

       78  DMPAPER-ENV-C5                 value          28.

       78  DMPAPER-ENV-C3                 value          29.

       78  DMPAPER-ENV-C4                 value          30.

       78  DMPAPER-ENV-C6                 value          31.

       78  DMPAPER-ENV-C65                value          32.

       78  DMPAPER-ENV-B4                 value          33.

       78  DMPAPER-ENV-B5                 value          34.

       78  DMPAPER-ENV-B6                 value          35.

       78  DMPAPER-ENV-ITALY              value          36.

       78  DMPAPER-ENV-MONARCH            value          37.

       78  DMPAPER-ENV-PERSONAL           value          38.

       78  DMPAPER-FANFOLD-US             value          39.

       78  DMPAPER-FANFOLD-STD-GERMAN     value          40.

       78  DMPAPER-FANFOLD-LGL-GERMAN     value          41.

       78  DMPAPER-ISO-B4                 value          42.

       78  DMPAPER-JAPANESE-POSTCARD      value          43.

       78  DMPAPER-9X11                   value          44.

       78  DMPAPER-10X11                  value          45.

       78  DMPAPER-15X11                  value          46.

       78  DMPAPER-ENV-INVITE             value          47.

       78  DMPAPER-RESERVED-48            value          48.

       78  DMPAPER-RESERVED-49            value          49.

       78  DMPAPER-LETTER-EXTRA           value          50.

       78  DMPAPER-LEGAL-EXTRA            value          51.

       78  DMPAPER-TABLOID-EXTRA          value          52.

       78  DMPAPER-A4-EXTRA               value          53.

       78  DMPAPER-LETTER-TRANSVERSE      value          54.

       78  DMPAPER-A4-TRANSVERSE          value          55.

       78  DMPAPER-LETTER-EXTRA-TRANSVERS value          56.

       78  DMPAPER-A-PLUS                 value          57.

       78  DMPAPER-B-PLUS                 value          58.

       78  DMPAPER-LETTER-PLUS            value          59.

       78  DMPAPER-A4-PLUS                value          60.

       78  DMPAPER-A5-TRANSVERSE          value          61.

       78  DMPAPER-B5-TRANSVERSE          value          62.

       78  DMPAPER-A3-EXTRA               value          63.

       78  DMPAPER-A5-EXTRA               value          64.

       78  DMPAPER-B5-EXTRA               value          65.

       78  DMPAPER-A2                     value          66.

       78  DMPAPER-A3-TRANSVERSE          value          67.

       78  DMPAPER-A3-EXTRA-TRANSVERSE    value          68.

       78  DMPAPER-LAST                   value          68.

       78  DMPAPER-USER                   value         256.

      * pr-papertray "bin" selections

       78  DMBIN-FIRST                    value   1.

       78  DMBIN-UPPER                    value   1.

       78  DMBIN-ONLYONE                  value   1.

       78  DMBIN-LOWER                    value   2.

       78  DMBIN-MIDDLE                   value   3.

       78  DMBIN-MANUAL                   value   4.

       78  DMBIN-ENVELOPE                 value   5.

       78  DMBIN-ENVMANUAL                value   6.

       78  DMBIN-AUTO                     value   7.

       78  DMBIN-TRACTOR                  value   8.

       78  DMBIN-SMALLFMT                 value   9.

       78  DMBIN-LARGEFMT                 value  10.

       78  DMBIN-LARGECAPACITY            value  11.

       78  DMBIN-CASSETTE                 value  14.

       78  DMBIN-FORMSOURCE               value  15.

       78  DMBIN-LAST                     value  15.

       78  DMBIN-USER                     value 256. *> device specific

      * pr-printquality settings

       78  DMRES-DRAFT                    value  -1.

       78  DMRES-LOW                      value  -2.

       78  DMRES-MEDIUM                   value  -3.

       78  DMRES-HIGH                     value  -4.

      * pr-color settings

       78  DMCOLOR-MONOCHROME             value   1.

       78  DMCOLOR-COLOR                  value   2.

      * pr-duplex settings

       78  DMDUP-SIMPLEX                  value   1.

       78  DMDUP-VERTICAL                 value   2.

       78  DMDUP-HORIZONTAL               value   3.

      * pr-orientation settings

       78  DMORIENT-PORTRAIT              value   1.

       78  DMORIENT-LANDSCAPE             value   2.

The PCPDP program initializes the "properties record" length.

           move length of properties to pr-len

Sets the flags for the "properties" that need to be adjusted.

           move P-PRINTQUALITY to flags

           add P-DUPLEX to flags

Enters the new values for the "properties".

           move DMRES-HIGH to pr-printquality

           move DMDUP-VERTICAL to pr-duplex

Calls the PC_PRINTER_DEFAULT_PROPERTIES  routine.

           call 'PC_PRINTER_DEFAULT_PROPERTIES'

               using by value     flags

                     by reference properties

               returning          status-code

           end-call

And checks the status-code.

           if status-code <> ZERO

             move status-code to pENumber

             call 'PrinterError'

             stop run

           end-if

It is important to understand that the PC_PRINTER_DEFAULT_PROPERTIES routine just saves the values that you set. These values do not get validated and used until you actually open a printer or attempt to print a file.

The PCPDP program includes a printer error table (PRNTERRW.CPY) and a routine that extracts and displays the error text from the table (PRNTERRP.CPY). The error message is displayed to the screen.

Included in the zip file is a Wordpad document named DEVMODE.doc. This is a copy of the Microsoft Win32 SDK documentation on the Device Mode data structure. You will notice the similarities in the Microsoft documentation and the Micro Focus documentation. If you haven't installed the Win32 SDK, it is located on the second CD provided with Net Express 3.1.

Attachments:

PROPERTIES.zip

Old KB# 4298