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 Windows | ScreenIO.com |
- 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.
- 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.
- 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.
Value | Meaning |
---|---|
DMPAPER-LETTER | Letter, 8 1/2- by 11-inches |
DMPAPER-LEGAL | Legal, 8 1/2- by 14-inches |
DMPAPER-10X14 | 10- by 14-inch sheet |
DMPAPER-11X17 | 11- by 17-inch sheet |
DMPAPER-12X11 | Windows 98/Me, Windows NT 4.0 and later: 12- by 11-inch sheet |
DMPAPER-A3 | A3 sheet, 297- by 420-millimeters |
DMPAPER-A3-ROTATED | Windows 98/Me, Windows NT 4.0 and later: A3 rotated sheet, 420- by 297-millimeters |
DMPAPER-A4 | A4 sheet, 210- by 297-millimeters |
DMPAPER-A4-ROTATED | Windows 98/Me, Windows NT 4.0 and later: A4 rotated sheet, 297- by 210-millimeters |
DMPAPER-A4SMALL | A4 small sheet, 210- by 297-millimeters |
DMPAPER-A5 | A5 sheet, 148- by 210-millimeters |
DMPAPER-A5-ROTATED | Windows 98/Me, Windows NT 4.0 and later: A5 rotated sheet, 210- by 148-millimeters |
DMPAPER-A6 | Windows 98/Me, Windows NT 4.0 and later: A6 sheet, 105- by 148-millimeters |
DMPAPER-A6-ROTATED | Windows 98/Me, Windows NT 4.0 and later: A6 rotated sheet, 148- by 105-millimeters |
DMPAPER-B4 | B4 sheet, 250- by 354-millimeters |
DMPAPER-B4-JIS-ROTATED | Windows 98/Me, Windows NT 4.0 and later: B4 (JIS) rotated sheet, 364- by 257-millimeters |
DMPAPER-B5 | B5 sheet, 182- by 257-millimeter paper |
DMPAPER-B5-JIS-ROTATED | Windows 98/Me, Windows NT 4.0 and later: B5 (JIS) rotated sheet, 257- by 182-millimeters |
DMPAPER-B6-JIS | Windows 98/Me, Windows NT 4.0 and later: B6 (JIS) sheet, 128- by 182-millimeters |
DMPAPER-B6-JIS-ROTATED | Windows 98/Me, Windows NT 4.0 and later: B6 (JIS) rotated sheet, 182- by 128-millimeters |
DMPAPER-CSHEET | C Sheet, 17- by 22-inches |
DMPAPER-DBL-JAPANESE-POSTCARD | Windows 98/Me, Windows NT 4.0 and later: Double Japanese Postcard, 200- by 148-millimeters |
DMPAPER-DBL-JAPANESE-POSTCARD-ROTATED | Windows 98/Me, Windows NT 4.0 and later: Double Japanese Postcard Rotated, 148- by 200-millimeters |
DMPAPER-DSHEET | D 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-C5 | C5 Envelope, 162- by 229-millimeters |
DMPAPER-ENV-C3 | C3 Envelope, 324- by 458-millimeters |
DMPAPER-ENV-C4 | C4 Envelope, 229- by 324-millimeters |
DMPAPER-ENV-C6 | C6 Envelope, 114- by 162-millimeters |
DMPAPER-ENV-C65 | C65 Envelope, 114- by 229-millimeters |
DMPAPER-ENV-B4 | B4 Envelope, 250- by 353-millimeters |
DMPAPER-ENV-B5 | B5 Envelope, 176- by 250-millimeters |
DMPAPER-ENV-B6 | B6 Envelope, 176- by 125-millimeters |
DMPAPER-ENV-DL | DL Envelope, 110- by 220-millimeters |
DMPAPER-ENV-ITALY | Italy Envelope, 110- by 230-millimeters |
DMPAPER-ENV-MONARCH | Monarch Envelope, 3 7/8- by 7 1/2-inches |
DMPAPER-ENV-PERSONAL | 6 3/4 Envelope, 3 5/8- by 6 1/2-inches |
DMPAPER-ESHEET | E Sheet, 34- by 44-inches |
DMPAPER-EXECUTIVE | Executive, 7 1/4- by 10 1/2-inches |
DMPAPER-FANFOLD-US | US Std Fanfold, 14 7/8- by 11-inches |
DMPAPER-FANFOLD-STD-GERMAN | German Std Fanfold, 8 1/2- by 12-inches |
DMPAPER-FANFOLD-LGL-GERMAN | German Legal Fanfold, 8 - by 13-inches |
DMPAPER-FOLIO | Folio, 8 1/2- by 13-inch paper |
DMPAPER-JAPANESE-POSTCARD-ROTATED | Windows 98/Me, Windows NT 4.0 and later: Japanese Postcard Rotated, 148- by 100-millimeters |
DMPAPER-JENV-CHOU3 | Windows 98/Me, Windows NT 4.0 and later: Japanese Envelope Chou #3 |
DMPAPER-JENV-CHOU3-ROTATED | Windows 98/Me, Windows NT 4.0 and later: Japanese Envelope Chou #3 Rotated |
DMPAPER-JENV-CHOU4 | Windows 98/Me, Windows NT 4.0 and later: Japanese Envelope Chou #4 |
DMPAPER-JENV-CHOU4-ROTATED | Windows 98/Me, Windows NT 4.0 and later: Japanese Envelope Chou #4 Rotated |
DMPAPER-JENV-KAKU2 | Windows 98/Me, Windows NT 4.0 and later: Japanese Envelope Kaku #2 |
DMPAPER-JENV-KAKU2-ROTATED | Windows 98/Me, Windows NT 4.0 and later: Japanese Envelope Kaku #2 Rotated |
DMPAPER-JENV-KAKU3 | Windows 98/Me, Windows NT 4.0 and later: Japanese Envelope Kaku #3 |
DMPAPER-JENV-KAKU3-ROTATED | Windows 98/Me, Windows NT 4.0 and later: Japanese Envelope Kaku #3 Rotated |
DMPAPER-JENV-YOU4 | Windows 98/Me, Windows NT 4.0 and later: Japanese Envelope You #4 |
DMPAPER-JENV-YOU4-ROTATED | Windows 98/Me, Windows NT 4.0 and later: Japanese Envelope You #4 Rotated |
DMPAPER-LAST | Windows 2000/XP: DMPAPER-PENV-10-ROTATED |
DMPAPER-LEDGER | Ledger, 17- by 11-inches |
DMPAPER-LETTER-ROTATED | Letter Rotated 11 by 8 1/2 11 inches |
DMPAPER-LETTERSMALL | Letter Small, 8 1/2- by 11-inches |
DMPAPER-NOTE | Note, 8 1/2- by 11-inches |
DMPAPER-P16K | Windows 98/Me, Windows NT 4.0 and later: PRC 16K, 146- by 215-millimeters |
DMPAPER-P16K-ROTATED | Windows 98/Me, Windows NT 4.0 and later: PRC 16K Rotated, 215- by 146-millimeters |
DMPAPER-P32K | Windows 98/Me, Windows NT 4.0 and later: PRC 32K, 97- by 151-millimeters |
DMPAPER-P32K-ROTATED | Windows 98/Me, Windows NT 4.0 and later: PRC 32K Rotated, 151- by 97-millimeters |
DMPAPER-P32KBIG | Windows 98/Me, Windows NT 4.0 and later: PRC 32K(Big) 97- by 151-millimeters |
DMPAPER-P32KBIG-ROTATED | Windows 98/Me, Windows NT 4.0 and later: PRC 32K(Big) Rotated, 151- by 97-millimeters |
DMPAPER-PENV-1 | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #1, 102- by 165-millimeters |
DMPAPER-PENV-1-ROTATED | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #1 Rotated, 165- by 102-millimeters |
DMPAPER-PENV-2 | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #2, 102- by 176-millimeters |
DMPAPER-PENV-2-ROTATED | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #2 Rotated, 176- by 102-millimeters |
DMPAPER-PENV-3 | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #3, 125- by 176-millimeters |
DMPAPER-PENV-3-ROTATED | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #3 Rotated, 176- by 125-millimeters |
DMPAPER-PENV-4 | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #4, 110- by 208-millimeters |
DMPAPER-PENV-4-ROTATED | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #4 Rotated, 208- by 110-millimeters |
DMPAPER-PENV-5 | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #5, 110- by 220-millimeters |
DMPAPER-PENV-5-ROTATED | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #5 Rotated, 220- by 110-millimeters |
DMPAPER-PENV-6 | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #6, 120- by 230-millimeters |
DMPAPER-PENV-6-ROTATED | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #6 Rotated, 230- by 120-millimeters |
DMPAPER-PENV-7 | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #7, 160- by 230-millimeters |
DMPAPER-PENV-7-ROTATED | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #7 Rotated, 230- by 160-millimeters |
DMPAPER-PENV-8 | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #8, 120- by 309-millimeters |
DMPAPER-PENV-8-ROTATED | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #8 Rotated, 309- by 120-millimeters |
DMPAPER-PENV-9 | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #9, 229- by 324-millimeters |
DMPAPER-PENV-9-ROTATED | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #9 Rotated, 324- by 229-millimeters |
DMPAPER-PENV-10 | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #10, 324- by 458-millimeters |
DMPAPER-PENV-10-ROTATED | Windows 98/Me, Windows NT 4.0 and later: PRC Envelope #10 Rotated, 458- by 324-millimeters |
DMPAPER-QUARTO | Quarto, 215- by 275-millimeter paper |
DMPAPER-STATEMENT | Statement, 5 1/2- by 8 1/2-inches |
DMPAPER-TABLOID | Tabloid, 11- by 17-inches |
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 |
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-COLOR
DMCOLOR-MONOCHROME
Value | Meaning |
---|---|
DMDUP-SIMPLEX | Normal (nonduplex) printing. |
DMDUP-HORIZONTAL | Short-edge binding, that is, the long edge of the page is horizontal. |
DMDUP-VERTICAL | Long-edge binding, that is, the long edge of the page is vertical. |
Value | Meaning |
---|---|
DMTT-BITMAP | Prints TrueType fonts as graphics. This is the default action for dot-matrix printers. |
DMTT-DOWNLOAD | Downloads TrueType fonts as soft fonts. This is the default action for Hewlett-Packard printers that use Printer Control Language (PCL). |
DMTT-DOWNLOAD-OUTLINE | Window 95/98/Me, Windows NT 4.0 and later: Downloads TrueType fonts as outline soft fonts. |
DMTT-SUBDEV | Substitutes device fonts for TrueType fonts. This is the default action for PostScript printers. |
Value | Meaning |
---|---|
DMCOLLATE-TRUE | Collate when printing multiple copies. |
DMCOLLATE-FALSE | Do not collate when printing multiple copies. |
Windows 95/98/Me: Printer drivers do not use this field.
Value | Meaning |
---|---|
DMNUP-SYSTEM | The print spooler does the NUP. |
DMNUP-ONEUP | The application does the NUP. |
Value | Meaning |
---|---|
DMICMMETHOD-NONE | Specifies that ICM is disabled. |
DMICMMETHOD-SYSTEM | Specifies that ICM is handled by Windows. |
DMICMMETHOD-DRIVER | Specifies that ICM is handled by the device driver. |
DMICMMETHOD-DEVICE | Specifies 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.
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.Value | Meaning |
---|---|
DMICM-ABS-COLORIMETRIC | Color matching should optimize to match the exact color requested without white point mapping. This value is most appropriate for use with proofing. |
DMICM-COLORMETRIC | Color 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-CONTRAST | Color matching should optimize for color contrast. This value is the most appropriate choice for scanned or photographic images when dithering is desired. |
DMICM-SATURATE | Color matching should optimize for color saturation. This value is the most appropriate choice for business graphs when dithering is not desired. |
Value | Meaning |
---|---|
DMMEDIA-STANDARD | Plain paper. |
DMMEDIA-GLOSSY | Glossy paper. |
DMMEDIA-TRANSPARENCY | Transparent film. |
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.Value | Meaning |
---|---|
DMDITHER-NONE | No dithering. |
DMDITHER-COARSE | Dithering with a coarse brush. |
DMDITHER-FINE | Dithering with a fine brush. |
DMDITHER-LINEART | Line 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-ERRORDIFFUSION | Windows 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-GRAYSCALE | Device does gray scaling. |
© 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: