Devmode Structure Printer Driver

  1. Printer Driver Epson
  2. Devmode Structure Printer Drivers

If you are truly using raw printer output, OpenPrinter etc, then changing DEVMODE will not have any effect, you are bypassing the printer driver. It is then completely up to you to rotate output. Quite painful if the printer itself doesn't support it. The kind where bypassing the driver makes sense never do. – Hans Passant Mar 18 '13 at 15:24.

GUI ScreenIOfor WindowsScreenIO.com

  1. Only be used to set printer model specific features, like stapler, etc. The Windows API 'DevMode' structure is used by Windows and the Printer Driver to define the printer setup. The name DevMode is short for DeviceMode.-Nard Moseley Digital Metaphors www.digital-metaphors.com.
  2. Foxit Quick PDF Library uses the standard Windows DEVMODE structure for printing which is used by many other programs as well. Unfortunately the printer driver manufacturers don’t use the values specified in the DEVMODE structure and instead use custom undocumented values. This means that the SetupCustomPrinter function works for many drivers but not every driver.
  3. If you are truly using raw printer output, OpenPrinter etc, then changing DEVMODE will not have any effect, you are bypassing the printer driver. It is then completely up to you to rotate output. Quite painful if the printer itself doesn't support it. The kind where bypassing the driver makes sense never do. – Hans Passant Mar 18 '13 at 15:24.

The GS-DEVMODE-DATA resides in the GSPRTDEF.COB copybook. This copybook holds what Microsoft calls DEVMODE data (Device Mode data) which is used to pass data to the printer sub-system to set up the printer.

The PrintDlg API will invoke the Standard Printer Dialog, and return this information to you in this data structure. The OpenPrinter API and the PrintFile API will pass this data to the printer. You may make changes to this information by using any of the settings provided in 88 items below. You need to set only those that are of interest to you, and you can allow the rest to default to the printer's default settings.

The definitions of the data names are below.

DMDEVICENAME
Specifies the 'friendly' name of the printer or display; for example, 'PCL/HP LaserJet' in the case of PCL/HP LaserJet. This string is unique among device drivers. Note that this name may be truncated to fit in the DMDEVICENAME array.
DMSPECVERSION
Specifies the version number of the initialization data specification on which the structure is based.
DMDRIVERVERSION
Specifies the driver version number assigned by the driver developer.
DMSIZE
Specifies the size, in bytes, of the DEVMODE portion of this structure, not including any auxiliary data that might follow.
DMDRIVEREXTRA
Contains the number of bytes of auxiliary driver-data that follow this structure. This may be zero.
DMFIELDS
Specifies whether certain items in structure have been initialized. If a field is initialized, its corresponding bit is set, otherwise the bit is clear.
DMORIENTATION
For printer devices only, selects the orientation of the paper. This field can be either DMORIENT-PORTRAIT (1) or DMORIENT-LANDSCAPE (2).
DMPAPERSIZE
For printer devices only, selects the size of the paper to print on. This field can be set to zero if the length and width of the paper are both set by the DMPAPERLENGTH and DMPAPERWIDTH fields. Otherwise, the DMPAPERSIZE field can be set to one of the following predefined values.
ValueMeaning
DMPAPER-LETTERLetter, 8 1/2- by 11-inches
DMPAPER-LEGALLegal, 8 1/2- by 14-inches
DMPAPER-10X1410- by 14-inch sheet
DMPAPER-11X1711- by 17-inch sheet
DMPAPER-12X11Windows 98/Me, Windows NT 4.0 and later: 12- by 11-inch sheet
DMPAPER-A3A3 sheet, 297- by 420-millimeters
DMPAPER-A3-ROTATEDWindows 98/Me, Windows NT 4.0 and later: A3 rotated sheet, 420- by 297-millimeters
DMPAPER-A4A4 sheet, 210- by 297-millimeters
DMPAPER-A4-ROTATEDWindows 98/Me, Windows NT 4.0 and later: A4 rotated sheet, 297- by 210-millimeters
DMPAPER-A4SMALLA4 small sheet, 210- by 297-millimeters
DMPAPER-A5A5 sheet, 148- by 210-millimeters
DMPAPER-A5-ROTATEDWindows 98/Me, Windows NT 4.0 and later: A5 rotated sheet, 210- by 148-millimeters
DMPAPER-A6Windows 98/Me, Windows NT 4.0 and later: A6 sheet, 105- by 148-millimeters
DMPAPER-A6-ROTATEDWindows 98/Me, Windows NT 4.0 and later: A6 rotated sheet, 148- by 105-millimeters
DMPAPER-B4B4 sheet, 250- by 354-millimeters
DMPAPER-B4-JIS-ROTATEDWindows 98/Me, Windows NT 4.0 and later: B4 (JIS) rotated sheet, 364- by 257-millimeters
DMPAPER-B5B5 sheet, 182- by 257-millimeter paper
DMPAPER-B5-JIS-ROTATEDWindows 98/Me, Windows NT 4.0 and later: B5 (JIS) rotated sheet, 257- by 182-millimeters
DMPAPER-B6-JISWindows 98/Me, Windows NT 4.0 and later: B6 (JIS) sheet, 128- by 182-millimeters
DMPAPER-B6-JIS-ROTATEDWindows 98/Me, Windows NT 4.0 and later: B6 (JIS) rotated sheet, 182- by 128-millimeters
DMPAPER-CSHEETC Sheet, 17- by 22-inches
DMPAPER-DBL-JAPANESE-POSTCARDWindows 98/Me, Windows NT 4.0 and later: Double Japanese Postcard, 200- by 148-millimeters
DMPAPER-DBL-JAPANESE-POSTCARD-ROTATEDWindows 98/Me, Windows NT 4.0 and later: Double Japanese Postcard Rotated, 148- by 200-millimeters
DMPAPER-DSHEETD Sheet, 22- by 34-inches
DMPAPER-ENV-9#9 Envelope, 3 7/8- by 8 7/8-inches
DMPAPER-ENV-10#10 Envelope, 4 1/8- by 9 1/2-inches
DMPAPER-ENV-11#11 Envelope, 4 1/2- by 10 3/8-inches
DMPAPER-ENV-12#12 Envelope, 4 3/4- by 11-inches
DMPAPER-ENV-14#14 Envelope, 5- by 11 1/2-inches
DMPAPER-ENV-C5C5 Envelope, 162- by 229-millimeters
DMPAPER-ENV-C3C3 Envelope, 324- by 458-millimeters
DMPAPER-ENV-C4C4 Envelope, 229- by 324-millimeters
DMPAPER-ENV-C6C6 Envelope, 114- by 162-millimeters
DMPAPER-ENV-C65C65 Envelope, 114- by 229-millimeters
DMPAPER-ENV-B4B4 Envelope, 250- by 353-millimeters
DMPAPER-ENV-B5B5 Envelope, 176- by 250-millimeters
DMPAPER-ENV-B6B6 Envelope, 176- by 125-millimeters
DMPAPER-ENV-DLDL Envelope, 110- by 220-millimeters
DMPAPER-ENV-ITALYItaly Envelope, 110- by 230-millimeters
DMPAPER-ENV-MONARCHMonarch Envelope, 3 7/8- by 7 1/2-inches
DMPAPER-ENV-PERSONAL6 3/4 Envelope, 3 5/8- by 6 1/2-inches
DMPAPER-ESHEETE Sheet, 34- by 44-inches
DMPAPER-EXECUTIVEExecutive, 7 1/4- by 10 1/2-inches
DMPAPER-FANFOLD-USUS Std Fanfold, 14 7/8- by 11-inches
DMPAPER-FANFOLD-STD-GERMANGerman Std Fanfold, 8 1/2- by 12-inches
DMPAPER-FANFOLD-LGL-GERMANGerman Legal Fanfold, 8 - by 13-inches
DMPAPER-FOLIOFolio, 8 1/2- by 13-inch paper
DMPAPER-JAPANESE-POSTCARD-ROTATEDWindows 98/Me, Windows NT 4.0 and later: Japanese Postcard Rotated, 148- by 100-millimeters
DMPAPER-JENV-CHOU3Windows 98/Me, Windows NT 4.0 and later: Japanese Envelope Chou #3
DMPAPER-JENV-CHOU3-ROTATEDWindows 98/Me, Windows NT 4.0 and later: Japanese Envelope Chou #3 Rotated
DMPAPER-JENV-CHOU4Windows 98/Me, Windows NT 4.0 and later: Japanese Envelope Chou #4
DMPAPER-JENV-CHOU4-ROTATEDWindows 98/Me, Windows NT 4.0 and later: Japanese Envelope Chou #4 Rotated
DMPAPER-JENV-KAKU2Windows 98/Me, Windows NT 4.0 and later: Japanese Envelope Kaku #2
DMPAPER-JENV-KAKU2-ROTATEDWindows 98/Me, Windows NT 4.0 and later: Japanese Envelope Kaku #2 Rotated
DMPAPER-JENV-KAKU3Windows 98/Me, Windows NT 4.0 and later: Japanese Envelope Kaku #3
DMPAPER-JENV-KAKU3-ROTATEDWindows 98/Me, Windows NT 4.0 and later: Japanese Envelope Kaku #3 Rotated
DMPAPER-JENV-YOU4Windows 98/Me, Windows NT 4.0 and later: Japanese Envelope You #4
DMPAPER-JENV-YOU4-ROTATEDWindows 98/Me, Windows NT 4.0 and later: Japanese Envelope You #4 Rotated
DMPAPER-LASTWindows 2000/XP: DMPAPER-PENV-10-ROTATED
DMPAPER-LEDGERLedger, 17- by 11-inches
DMPAPER-LETTER-ROTATEDLetter Rotated 11 by 8 1/2 11 inches
DMPAPER-LETTERSMALLLetter Small, 8 1/2- by 11-inches
DMPAPER-NOTENote, 8 1/2- by 11-inches
DMPAPER-P16KWindows 98/Me, Windows NT 4.0 and later: PRC 16K, 146- by 215-millimeters
DMPAPER-P16K-ROTATEDWindows 98/Me, Windows NT 4.0 and later: PRC 16K Rotated, 215- by 146-millimeters
DMPAPER-P32KWindows 98/Me, Windows NT 4.0 and later: PRC 32K, 97- by 151-millimeters
DMPAPER-P32K-ROTATEDWindows 98/Me, Windows NT 4.0 and later: PRC 32K Rotated, 151- by 97-millimeters
DMPAPER-P32KBIGWindows 98/Me, Windows NT 4.0 and later: PRC 32K(Big) 97- by 151-millimeters
DMPAPER-P32KBIG-ROTATEDWindows 98/Me, Windows NT 4.0 and later: PRC 32K(Big) Rotated, 151- by 97-millimeters
DMPAPER-PENV-1Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #1, 102- by 165-millimeters
DMPAPER-PENV-1-ROTATEDWindows 98/Me, Windows NT 4.0 and later: PRC Envelope #1 Rotated, 165- by 102-millimeters
DMPAPER-PENV-2Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #2, 102- by 176-millimeters
DMPAPER-PENV-2-ROTATEDWindows 98/Me, Windows NT 4.0 and later: PRC Envelope #2 Rotated, 176- by 102-millimeters
DMPAPER-PENV-3Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #3, 125- by 176-millimeters
DMPAPER-PENV-3-ROTATEDWindows 98/Me, Windows NT 4.0 and later: PRC Envelope #3 Rotated, 176- by 125-millimeters
DMPAPER-PENV-4Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #4, 110- by 208-millimeters
DMPAPER-PENV-4-ROTATEDWindows 98/Me, Windows NT 4.0 and later: PRC Envelope #4 Rotated, 208- by 110-millimeters
DMPAPER-PENV-5Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #5, 110- by 220-millimeters
DMPAPER-PENV-5-ROTATEDWindows 98/Me, Windows NT 4.0 and later: PRC Envelope #5 Rotated, 220- by 110-millimeters
DMPAPER-PENV-6Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #6, 120- by 230-millimeters
DMPAPER-PENV-6-ROTATEDWindows 98/Me, Windows NT 4.0 and later: PRC Envelope #6 Rotated, 230- by 120-millimeters
DMPAPER-PENV-7Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #7, 160- by 230-millimeters
DMPAPER-PENV-7-ROTATEDWindows 98/Me, Windows NT 4.0 and later: PRC Envelope #7 Rotated, 230- by 160-millimeters
DMPAPER-PENV-8Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #8, 120- by 309-millimeters
DMPAPER-PENV-8-ROTATEDWindows 98/Me, Windows NT 4.0 and later: PRC Envelope #8 Rotated, 309- by 120-millimeters
DMPAPER-PENV-9Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #9, 229- by 324-millimeters
DMPAPER-PENV-9-ROTATEDWindows 98/Me, Windows NT 4.0 and later: PRC Envelope #9 Rotated, 324- by 229-millimeters
DMPAPER-PENV-10Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #10, 324- by 458-millimeters
DMPAPER-PENV-10-ROTATEDWindows 98/Me, Windows NT 4.0 and later: PRC Envelope #10 Rotated, 458- by 324-millimeters
DMPAPER-QUARTOQuarto, 215- by 275-millimeter paper
DMPAPER-STATEMENTStatement, 5 1/2- by 8 1/2-inches
DMPAPER-TABLOIDTabloid, 11- by 17-inches
DMPAPERLENGTH
For printer devices only, overrides the length of the paper specified by the DMPAPERSIZE field, either for custom paper sizes or for devices such as dot-matrix printers that can print on a page of arbitrary length. These values, along with all other values in this structure that specify a physical length, are in tenths of a millimeter.
DMPAPERWIDTH
For printer devices only, overrides the width of the paper specified by the DMPAPERSIZE field.
DMSCALE
Specifies the factor by which the printed output is to be scaled. The apparent page size is scaled from the physical page size by a factor of DMSCALE/100. For example, a letter-sized page with a DMSCALE value of 50 would contain as much data as a page of 17- by 22-inches because the output text and graphics would be half their original height and width. nORMALLY SET TO 100.
DMCOPIES
Selects the number of copies printed if the device supports multiple-page copies.
DMDEFAULTSOURCE
Specifies the paper source. To retrieve a list of the available paper sources for a printer. This field can be one of the following values, or it can be a device-specific value greater than or equal to DMBIN-USER.
DMBIN-AUTO
DMBIN-CASSETTE
DMBIN-ENVELOPE
DMBIN-ENVMANUAL
DMBIN-FORMSOURCE
DMBIN-LARGECAPACITY
DMBIN-LARGEFMT
DMBIN-LOWER
DMBIN-MANUAL
DMBIN-MIDDLE
DMBIN-ONLYONE
DMBIN-TRACTOR
DMBIN-SMALLFMT

DMPRINTQUALITY
Specifies the printer resolution. There are four predefined device-independent values: (NEGATIVE values)

DMRES-HIGH
DMRES-MEDIUM
DMRES-LOW
DMRES-DRAFT

If a positive value is specified, it specifies the number of dots per inch (DPI) and is therefore device dependent.

DMCOLOR
Switches between color and monochrome on color printers. Following are the possible values:

DMCOLOR-COLOR
DMCOLOR-MONOCHROME

DMDUPLEX
Selects duplex or double-sided printing for printers capable of duplex printing. Following are the possible values.
ValueMeaning
DMDUP-SIMPLEXNormal (nonduplex) printing.
DMDUP-HORIZONTALShort-edge binding, that is, the long edge of the page is horizontal.
DMDUP-VERTICALLong-edge binding, that is, the long edge of the page is vertical.

DMYRESOLUTION
Specifies the y-resolution, in dots per inch, of the printer. If the printer initializes this field, the DMPRINTQUALITY field specifies the x-resolution, in dots per inch, of the printer.
DMTTOPTIONS
Specifies how TrueType fonts should be printed. This field can be one of the following values.
ValueMeaning
DMTT-BITMAPPrints TrueType fonts as graphics. This is the default action for dot-matrix printers.
DMTT-DOWNLOADDownloads TrueType fonts as soft fonts. This is the default action for Hewlett-Packard printers that use Printer Control Language (PCL).
DMTT-DOWNLOAD-OUTLINEWindow 95/98/Me, Windows NT 4.0 and later: Downloads TrueType fonts as outline soft fonts.
DMTT-SUBDEVSubstitutes device fonts for TrueType fonts. This is the default action for PostScript printers.

DMCOLLATE
Specifies whether collation should be used when printing multiple copies. (This field is ignored unless the printer driver includes support for collation. This field can be one of the following values.
ValueMeaning
DMCOLLATE-TRUECollate when printing multiple copies.
DMCOLLATE-FALSEDo not collate when printing multiple copies.

DMFORMSNAME
Windows NT/2000/XP: Specifies the name of the form to use; for example, 'Letter' or 'Legal'. Driver

Windows 95/98/Me: Printer drivers do not use this field.

DMNUP
Specifies where the NUP is done. It can be one of the following. NUP = N Up, as in 3-up labels etc.
ValueMeaning
DMNUP-SYSTEMThe print spooler does the NUP.
DMNUP-ONEUPThe application does the NUP.

DMICMMETHOD
Windows 95/98/Me; Windows 2000/XP: Specifies how ICM is handled. For a non-ICM application, this field determines if ICM is enabled or disabled. For ICM applications, the system examines this field to determine how to handle ICM support. This field can be one of the following predefined values, or a driver-defined value greater than or equal to the value of DMICMMETHOD-USER.
ValueMeaning
DMICMMETHOD-NONESpecifies that ICM is disabled.
DMICMMETHOD-SYSTEMSpecifies that ICM is handled by Windows.
DMICMMETHOD-DRIVERSpecifies that ICM is handled by the device driver.
DMICMMETHOD-DEVICESpecifies that ICM is handled by the destination device.

The printer driver must provide a user interface for setting this field. Most printer drivers support only the DMICMMETHOD-SYSTEM or DMICMMETHOD-NONE value. Drivers for PostScript printers support all values.

CMICMINTENT
Windows 95/98/Me, Windows 2000/XP: Specifies which color matching method, or

Printer Driver Epson

intent, should be used by default. This field is primarily for non-ICM applications. ICM applications can establish intents by using the ICM functions. This field can be one of the following predefined values, or a driver defined value greater than or equal to the value of DMICM-USER.
ValueMeaning
DMICM-ABS-COLORIMETRICColor matching should optimize to match the exact color requested without white point mapping. This value is most appropriate for use with proofing.
DMICM-COLORMETRICColor matching should optimize to match the exact color requested. This value is most appropriate for use with business logos or other images when an exact color match is desired.
DMICM-CONTRASTColor matching should optimize for color contrast. This value is the most appropriate choice for scanned or photographic images when dithering is desired.
DMICM-SATURATEColor matching should optimize for color saturation. This value is the most appropriate choice for business graphs when dithering is not desired.

DMMEDIATYPE
Windows 95/98/Me, Windows 2000/XP: Specifies the type of media being printed on. The field can be one of the following predefined values, or a driver-defined value greater than or equal to the value of DMMEDIA-USER.
ValueMeaning
DMMEDIA-STANDARDPlain paper.
DMMEDIA-GLOSSYGlossy paper.
DMMEDIA-TRANSPARENCYTransparent film.

DMDITHERTYPE

Devmode Structure Printer Drivers

Windows 95/98/Me, Windows 2000/XP: Specifies how dithering is to be done. The field can be one of the following predefined values, or a driver-defined value greater than or equal to the value of DMDITHER-USER.
ValueMeaning
DMDITHER-NONENo dithering.
DMDITHER-COARSEDithering with a coarse brush.
DMDITHER-FINEDithering with a fine brush.
DMDITHER-LINEARTLine art dithering, a special dithering method that produces well defined borders between black, white, and gray scaling. It is not suitable for images that include continuous graduations in intensity and hue, such as scanned photographs.
DMDITHER-ERRORDIFFUSIONWindows 95/98/Me: Dithering in which an algorithm is used to spread, or diffuse, the error of approximating a specified color over adjacent pixels. In contrast, DMDITHER-COARSE, DMDITHER-FINE, and DMDITHER-LINEART use patterned halftoning to approximate a color.
DMDITHER-GRAYSCALEDevice does gray scaling.
DM-RESERVED
(just what it says)
© 2000-2019 Norcom, all rights reserved

The usage of DocumentProperties and SetPrinter API functions gives an opportunity to change the printer settings. But, when using them, I could not have a stable method of changing settings on all Windows OS versions. Below, all possible methods of changing printer parameters will be described and also the solution of how to obtain the stabler behavior for different Windows OS versions. In this article, I will describe the method of setting the printer settings and the problems I faced on different OS versions.

Changing Printer Settings

You can change the printer settings with the help of API:

  • DocumentProperties - retrieves and changes the printer parameters;
  • SetPrinter - determines data for printer, changes the state, and also can manage the printing and tasks.

Changing Settings Using the DocumentProperties Function

To use the DocumentProperties function to change the printer settings, you should do as follows:

  • Get the number of bytes required for the DEVMODE structure: