USOO6825941B1 (12) United States Patent (10) Patent No.: US 6,825,941 B1 Nguyen et al. (45) Date of Patent: Nov.30, 2004

(54) MODULAR AND EXTENSIBLE Primary Examiner-Gabriel Garcia DEVICE DRIVER AND TEXT BASED Assistant Examiner Douglas Tran METHOD FOR CHARACTERIZING (74) Attorney, Agent, or Firm-Leydig, Voit & Mayer, Ltd. PRINTER DEVICES FOR USE THEREWITH (57) ABSTRACT (75) Inventors: Amanda Nguyen, Bothell, WA (US); Ganesh Pandey, Kirkland, WA (US); A modular Universal is provided which Alvin Scholten, Redmond, WA (US); dramatically improves the extensibility of the driver archi Zhanbing Wu, Bellevue, WA (US); tecture and the Support for printer features. This driver Eigo Shimizu, Seattle, WA (US); Peter operates in conjunction with OEM developed minidrivers Wong, Woodinville, WA (US) which utilize the text based Generic Printer Description (73) Assignee: Microsoft Corporation, Redmond, WA (GPD) format of the instant invention. The universal driver (US) allows the GPD text based minidrivers to add and define new features introduced by the printer OEM. The universal driver (*) Notice: Subject to any disclaimer, the term of this also allows the GPD minidriver to modify, add, or replace patent is extended or adjusted under 35 the standard user interface provided by the universal driver. U.S.C. 154(b) by 890 days. The universal driver and the text based GPD minidrivers are included in a computer System for outputting data to an (21) Appl. No.: 09/157,895 output device, Such as a printer. This System includes an (22) Filed: Sep. 21, 1998 application program which invokes a plurality of graphics device interface functions to control the Sending of data to (51) Int. Cl." ...... G06F 3/12; G06F 13/00 the printer. Within the System, a graphics device interface (52) U.S. Cl...... 358/1.15; 358/1.13 invokes device driver functions for controlling the output (58) Field of Search ...... 358/1.15, 1.11, ting of data. The text based minidriver contains a charac 358/1.13 terization of the output device, and an implementation of (56) References Cited device specific device driver functions invoked by the graphic device interface. This text based minidriver outputs U.S. PATENT DOCUMENTS this data to the universal driver. This universal driver incor 5,604.843 A 2/1997 Shaw et al...... 395/101 porates the text based characterization passed by the minid 5,619,635 A * 4/1997 Millman et al...... 395/768 river. The universal driver implements the device specific OTHER PUBLICATIONS driver functions and controls the outputting of data to the printer in accordance with the incorporated text based char The Unicode Standard Version 2.0, The Unicode Consor acterization. tium, Addison-Wesley Press, 1997. * cited by examiner 22 Claims, 16 Drawing Sheets

102 04 106

Generic Printer Description File PARSER Internal Binary DataStructures (cached in file)

Driver Rendering DLL DRIVER USER

INTERFACEDLL 112. (handles DEVMODE, 116 devicaps, etc.)

110

118 PDEW, gdi OBS, PRINTER OUTPUTDATA Printer Settings (devmode)

WECTOR FONT MODULE MODULE 120

miniPDev, output data miniPDev, output data miniPDev, output data output cmds

OEM CUSTOM OEMFONT OEMCUSTOM OEM CUSTOM WECTOR GRX DOWNLOADING RASTER GRX UMODULE 1247 128/ 128/ 14.

U.S. Patent Nov.30, 2004 Sheet 3 of 16 US 6,825,941 B1

RMDERING MODULE U.S. Patent Nov.30, 2004 Sheet 4 of 16 US 6,825,941 B1

(STARD -70 REQUEST CURRENT VERSION Fig. 4 INTERFACE 72

CURRENT VERSION No SUPPORTED

REQUEST NEXT OLDER

Yes VERSION OF 74

USE CURRENT INTERFACE VERSION OF INTERFACE 82 78

NEXT OLDERVERSION (END) SUPPORTED REQUEST NEXT OLDER Yes VERSION OF USE NEXT OLDER INTERFACE VERSION OF INTERFACE NEXT 84 OLDERVERSION SUPPORTED Y

USE NEXT OLDER VERSION OF INTERFACE U.S. Patent Nov.30, 2004 Sheet 5 of 16 US 6,825,941 B1

64

Driver

ra Driver calls Returns Calls Calls Return pointer ClassFactory-> Unknown Unknown-> DIGetClassObject to ClassFacto Createlnstance interface QueryInterface pointer For all supported interfaces

OEM Customization DLL t | o Driver

OEM returns Driver passes OEM Calls NOW both OEM Interface Unknown unknown-> and Driver has Pointer for interface QueryInterface to Known interfaces Highest to OEM using get the of each other. Known Publish.Driverinter highest known They use interface face helper function interface methods Method of OEM interface. to call interface. OEM Customization DLL e FIG.5 U.S. Patent Nov.30, 2004 Sheet 6 of 16 US 6,825,941 B1

INTERNAL PPD/GPD Parsers BINARY DATA

WINSPOOL UMODULE DEVMODE, PRINTERDATA

COMPSTU OEM U MODULE

FIG. 6 62 U.S. Patent Nov.30, 2004 Sheet 7 of 16 US 6,825,941 B1

§§§§? No.ž s

FG. 7

U.S. Patent Nov.30, 2004 Sheet 8 of 16 US 6,825,941 B1

edius & aggress Adarted ournart Settings i. Peger'Output " - - Cogy Count Cogy 3-3 Paper Option : i Paper Option 2 l Graphic

or Print Quality. Draft El-SEmage Color Matching

- ICM Method...ag r. ICM intent. Brasia:3: :- - - Scaling 100% litheritag: Ele - - - TrueType Fort 2:38:28: |-9 Graphic option 1 El-El Graphic Option 3 s is Document Options ... utput Bir Trey Assignment: Eiddle Tray " '''eter Mark FIENTIAL - HellFire:Jse Syster

ir irriage Coldf. Halfline Coloradjustmgn:

F.G. 8 U.S. Patent Nov.30, 2004 Sheet 9 of 16 US 6,825,941 B1

90

Public DEVMODE dmExtraData

Driver extra data dmOEMDriverExtra

OEMU 1 extra date (its private DEVMODE)

OEMU 2 extra date (its private DEVMODE)

FIG. 9 U.S. Patent Nov.30, 2004 Sheet 10 of 16 US 6,825,941 B1

OEM U 1 extra data

dwSize dwSignature dwVersion, U.S. Patent Nov.30, 2004 Sheet 11 of 16 US 6,825,941 B1

go

pPublicDMin = pPublicDMOut = 0 Public DEVMODE dmExtraData

Driver extra data dmOEMDriverExtra

OEMU 1 extra date (its private DEVMODE) cbBufSize = size of extr pOEMDMin = 0 pOEMDMOut =

OEMU 2 extra date (its private DEVMODE) 94

FIG. 11 U.S. Patent Nov.30, 2004 Sheet 12 of 16 US 6,825,941 B1

pPublicDMln pPublicDMOut > Other Version Current Version

Public DEVMODE dmExtraData Public DEVMODE 96 dmExtra Data

pOEMDMIn Driver extra data dmOEMDriverExtra 98

Driver extra data dmOEMDriverExtra OEM U 1 extra date (its private DEVMODE) role

OEMU 2 extra date CbBufSize (its private DEVMODE) OEM U 1 extra date (its private DEVMODE)

OEM U 2 extra date (its private DEVMODE)

F.G. 12 U.S. Patent Nov.30, 2004 Sheet 13 of 16 US 6,825,941 B1

pPublicDMIn pPublicDMOut Current Version Current Version

Public DEVMODE Public DEVMODE dmExtraData dmExtraData

96 98

Driver extra data Driver extra data dmOEMDriverExtra dmOEMDriverExtra re pOEMDMOut

cbBufSize OEM U 1 extra date CbBufSize OEM U 1 extra date (its private DEVMODE) (its private DEVMODE)

OEMU 2 extra date OEM U 2 extra date (its private DEVMODE) (its private DEVMODE)

FIG. 13

U.S. Patent Nov.30, 2004 Sheet 15 of 16 US 6,825,941 B1

APPLICATION i PROGRAM . i GRAPHICS DEVICE INTERFACE :

| i

Fig. 15 PRIOR ART U.S. Patent Nov.30, 2004 Sheet 16 of 16 US 6,825,941 B1

APPLICATION PROGRAM 18

PRINTER PRINTER 1 2

Fig. 16 US 6,825,941 B1 1 2 MODULAR AND EXTENSIBLE PRINTER terization which is needed to drive the individual printers. As DEVICE DRIVER AND TEXT BASED illustrated in FIG.16, the computer system 19 implementing METHOD FOR CHARACTERIZING the universal driver Still utilizes the graphics device interface PRINTER DEVICES FOR USE THEREWITH (GDI) 14 as a means of coordinating the output from the various application programs. The GDI 14 function invokes the device driver functions of a minidriver 17, 17, ... 17, FIELD OF THE INVENTION which correspond to and contain the characterization of individual printer devices 10, 10, ... 10. This invention relates to output device characterization The difference in this system from that illustrated in FIG. methods and device drivers, and more particularly to a 15 is that the operating system includes the unidriver 15 method for characterizing and customizing output printer which includes a Standard Set of device driver functions devices and a driver architecture for use therewith. required to drive a printing device. In this way, the indi vidual printer manufactures need not provide this coding. In BACKGROUND OF THE INVENTION order to actually drive any particular printer device, the The phenomenal growth of the computer industry in both 15 unidriver 15 must receive individual printer characterization the commercial and consumer market Segments has spawned information from a selected minidriver 17. The universal an increasing number of companies who provide both Soft driver 15 then stores this device characterization data, pref ware and peripheral hardware products to the market. It erably within a device context, to be used by the device becomes the job of the operating System designer to coor driver functions of the universal driver 15. Other device dinate and ensure compatibility of data flow within, driver functions of the minidriver 17 forward their invoca between, and without of the computers on which this soft tion to the universal driver 15 by invoking an analogous ware and peripheral hardware is installed. To ensure that the function of the universal driver 15. In this way, the printer literally thousands of application programs are able to output hardware manufacturer needs only Supply a relatively Small their data to peripheral printing devices, the operating Sys minidriver which contains characterization data for their tem designers have developed a graphics device interface 25 particular device and which will be used by the unidriver 15 (GDI). The GDI affects the output data from the application to actually drive the printer. This unidriver/minidriver sys programs by invoking functions which allow access to tem is described in U.S. Pat. No. 5,604.843 to Shaw et al. for printing devices in a device-independent manner. This GDI METHOD AND SYSTEM FOR INTERFACING WITH A provides a uniform interface between the literally thousands COMPUTER OUTPUT DEVICE, the disclosure and teach of application programs and the output peripheral devices to ings of which are incorporated herein by reference. which these programs wish to Send data to be printed. While this System provides significant advantages over While the GDI provides a uniform interface from the the prior operating system requirement of large monolithic application programs, it is unable to produce actual printer printer drivers, the inability of this universal driver 15 to control commands which are capable of driving each of the Support continued advances from printer manufacturers, and hundreds of different models of printer devices available on 35 the difficulty of coding and debugging the required minid the market. In the past each individual printer 10, 10, . . . river format has become apparent. Specifically, the archi 10, required its own individual printer driver 12, 12, . . . tecture of this prior universal printer driver could be likened 12, as illustrated in FIG. 15. These individual printer drivers to a database into which individual printer characterization 12, 12, ... 12, implemented various control functions for data from the minidriver must be directly mapped. AS Such, their respective printers based upon the Standardized output 40 new features Supplied by the printer manufacturers could not from the graphics device interface 14. These Standard func be Supported by the universal driver because there was tions included initialization, information, output, attribute, nowhere within the universal driver for this new function to mode, and escape. While each of these individual monolithic be mapped. A new feature could only be implemented if its printer drivers provided the necessary interface to allow Support were included in a new release of a new version of proper driving of each individual printer model, they were 45 the universal driver. However, new version releases often typically were Several megabytes in size. The need for Such lagged quite significantly behind the introduction of new extensive printer dirVerS impacted not only the individual printers having advanced features. As a result of this inabil printer manufacturer, but also the individual computer SyS ity to map new features into the existing universal driver, tem 16 into which it was to be installed. Specifically, a many original equipment manufacturers (OEMs) reverted to computer System 16 would require a Significant amount of 50 writing their own monolithic printer drivers to allow full memory dedicated to the Storage of individual printer drivers Support functionality of their new printing devices. if more then one printer were to be Supported by the System Additionally, the Structure of the universal driver required 16. This obviously limited the space remaining within the that the minidrivers be of a specific binary format. Since computer System 16 for Storage of application programs 18. development and coding of these binary minidrivers was In addition, because of the complexity of printer drivers, 55 difficult at best, MicroSoft introduced a graphical user inter different printer drivers tend to have various quirks (or bugs) face (GUI) tool called unitool to aid the software engineer in that cause great headache for application developerS. Writing these minidrivers. This unitool driven generic printer Consistent, high-quaility printing is a luxury for users. For characterization (GPC) was intended to provide an applica the same reason, many printer devices do not have drivers tion independent way of describing the total functionality for everyOS platoform. For example, many popular con 60 and capabilities of one or more printerS Supplied by a printer Sumer printers dondo nott have Windows NT drivers. OEM. Once this GPC file had been written using the unitool For the purpose of easing the development of Windows GUI, it was then compiled and linked into a resource DLL. printer drivers and improving the driver quality acroSS the This compiled and linked resource DLL was then installed board, engineers at MicroSoft developed a new universal for use by the universal driver. Unfortunately, if a bug were printer driver to be included within the Windows operating 65 discovered in the GPC file, the entire process would need to System. This new universal printer driver included a stan be repeated. This process included accessing the unitool dard Set of device driver functions based on device charac GUI, modifying the binary GPC characterization file, US 6,825,941 B1 3 4 recompiling and relinking this GPC file into the resource This allows minidriver developers to specify which printer DLL, and then reinstalling this compiled and linked resource options are installable. The driver UI asks the user which DLL for use by the unidriver. This significantly impacted the options are actually installed and allow users to Select only time required for debugging and development of the indi those that are installed. Fourth, GPD provides support for vidual minidrivers. various types of constraints. This allows minidriver devel Because of its rigid architecture, the universal driver operS to Specify constraints between option Selections, Such provided very limited Support for any customization, and as “the combination of 720 dpi, plain paper and color that which was provided was only in the areas of command printing is an invalid configuration', or constraints between callback, raster dump, filter graphics, and font related call option installations, or constraints between option installa backs. Additionally, the universal printer driver architecture tion and option Selection. was neither modular nor extensible further limiting its Additionally, GPD provides support for value depen ability to allow for customized support of new features. This dency. This generic mechanism gives minidriver developerS resulted in a master-Slave relationship between the universal great power to describe any kind of dependency between driver and the minidriver, constraining the Support and printer commands and/or attributes. Combined with the new functionality to its implemented Structure and Supported 15 command parameter Specification Scheme, it significantly features. This resulted in a great deal of consternation within reduces the need to write command callback code. Further, the printer OEM community. GPD provides a new command parameter Specification Scheme. In GPC, each printing command (ex. X-move-to) SUMMARY OF THE INVENTION has a pre-defined list of parameters and there are only The universal printer driver (Unidrvis) of the instant limited ways (as supported in EXTCD structure) to manipu invention is a new 32-bit universal printer driver developed late the actual parameter values. GPD, however, allows each by Microsoft for initial implementation in Windows NT5.0. command to pick any parameters from a pool of Standard Compared to previous versions of a universal printer driver variables (essentially a partial Snapshot of the printer and in various Windows operating systems (OS), the Unidrvis of driver state that the Unidrvis maintains). GPD also supports the instant invention is designed to dramatically improve the 25 arbitrary arithmetic manipulation of these parameters. extensibility of the driver architecture and the support for Additionally, GPD provides great extensibility. It is very printer features. A key new feature of the instant invention easy to add new features, printer commands or attributes to includes a new printer data description format called the GPD file without any impact on Unidrvis. The GPD Generic Printer Description (GPD). Compared to GPC/ parser parses the data into a single binary format and UNITOOL described above, GPD offers much improved UnidrV5 never needs to worry about different binary capability to describe printer devices. The architecture of formats, as was the case with GPC revisions. UnidrV5 also Supports extensive original equipment manu The driver user interface (UI) of the Unidrvis utilizes a facturer (OEM) customization interface. This extensibility similar tree view UI as used by Windows NT4.0 printer allowS OEMs to plug in Special code for customizing the drivers, as shown in FIG. 7. Standard Properties are included UI, bitmap handling, font and text processing, and general 35 on the layout and paper/quality property sheets illustrated in printer control. FIG. 8. The Unidrvis of the instant invention utilizes a flexible The driver UI, implemented as the user-mode modular architecture which allows enhancements to the DRIVERUI.DLL, displays all printer features specified in driver to be implemented to provide better support for more 40 GPD, whether they are standard or generic. For generic varieties of output devices, and to improve the output features, they are displayed in the order listed in the GPD file quality, ease of use and performance without the necessity generally. The driver UI also enforces the constraints Speci for redesign. Examples include the Support for a generic font fied in the GPD file. It checks on installable options and installer interface, limited vector printing capability, using allow users to Select only those options that are actually page content analysis to improve printing quality and 45 installed. performance, and offering more flexibility in UI customiza The UnidrV5 of the instant invention preferably is titled tion including complete UI functionality replacement. UNIDRV.DLL. It handles all DDI calls and generates Generic Printer Description (GPD) is a new text-based printer-specific output data based on information in the printer description file format for creating minidrivers that given GPD file. UnidrV5 also handles raster printing. run with the UnidrV5 of the instant invention. In a preferred 50 UnidrV5 Supports a large Set of printer raster data formats. embodiment of the instant invention, there is one GPD file This includes all types of dot-matrix printers, Serial inkjet for each printer model. But different printers can share GPD printers, and page printers. Both monochrome and color data by using the Include capability in GPD. A GPD file printing are Supported. In fact, the minidriver developer can describes all the features on a printer and how to display and define multiple color printing modes in GPD, for example, invoke these features. It also contains printer-specific com 55 one with driver rendering in 4 bpp format and another in 24 mands and attributes that enable the UnidrV5 to generate the bpp format. UnidrV5 performs the necessary data conversion correct printer-ready output data. Compared to the binary and/or halftone to generate raster data ready for the printer. based GPC file format used by previous versions of The GPD file can specify what is the default printing mode. UNIDRV, GPD offers several key advantages. It could even Suppress the monochrome mode if desired. First, GPD provides support for generic features. This 60 UnidrV5 also provides color matching Support by using allows adding Support for new printer features (Such as Print ICM2.0 on the host machine. Printer vendors can provide Density, Stapling, etc.) without any change to the UnidrV5. ICC color profiles for their printers and make the association Second, GPD also provides Support for custom help. A via the printer's INF file. printer vendor can specify a custom help file to augment the UnidrV5 Supports device-resident fonts, font cartridges, default help file, which would provide users specific 65 host-based bitmap fonts, and host-based TrueType fonts. context-sensitive help for generic features and other fea UnidrV5 has built-in support for incremental downloading of tures. Third, GPD provides Support for installable options. TrueType fonts as PCL soft fonts (bitmap and maybe US 6,825,941 B1 S 6 outline). It also supports OEM plug-in's to download Tru FIG. 8 is a UI default document properties advanced sheet eType fonts in other printer-specific formats. UnidrV5 also illustration as generated in accordance with an embodiment supports FE fonts and wide device fonts (i.e. fonts with more of the instant invention; than 256 glyphs). It also Supports font Substitution FIG. 9 is a simplified data Structure diagram illustrating an (Substituting device fonts for system TrueType fonts for aspect of the instant invention; better performance). FIG. 10 is a simplified data structure diagram illustrateing In the render mode, OEM’s can write a plug-in module to an aspect of the instant invention; extend the capability of Unidrvis in the various areas. First, FIG. 11 is a simplified data Structure diagram illustrating an OEM can extend the capability of Unidrvis in the area of an aspect of the instant invention; raster data processing. UnidrV5 allows OEMs to hook out 1O raster processing at two levels: at the band level where FIG. 12 is a simplified data Structure diagram illustrating UnidrV5 would pass a whole band of data; or at the Scanline an aspect of the instant invention; level where UnidrV5 would pass a buffer of raster data for FIG. 13 is a simplified data Structure diagram illustrating feeding one print head pass. OEMs can also define custom an aspect of the instant invention; halftone patterns (up to 256x256 size) in the GPD file. 15 FIG. 14 is a simplified data Structure diagram illustrating UnidrV5 passes the information of the currently selected an aspect of the instant invention; halftone pattern to GDI which uses it instead of a standard FIG. 15 is a simplified block diagram of a prior operating system halftone pattern. Second, an OEM can extend the System requiring individual printer drivers for each indi capability of UnidrV5 in the area of font downloading. vidual printer; and UnidrV5 Supports an extensible font downloading interface FIG. 16 is a simplified block diagram of an overall to allow minidrivers to support non-PCL formats. computer System architecture incorporating minidrivers and Additionally, an OEM can extend the capability of UnidrV5 a unidriver to provide appropriate interface and control of in the area of command callbacks. For any GPD command, multiple printers. the minidriver can Specify a callback id in order to gain 25 While the invention is susceptible of various modifica control at the point of emitting that particular command. tions and alternative constructions, certain illustrative This essentially gives minidrivers an extensive Set of injec embodiments thereof have been shown in the drawings and tion points where they can influence the output data Stream will be described below in detail. It should be understood, dynamically. OEM’s can also hook out any DDI function for however, that there is no intention to limit the invention to State checking and information caching. the Specific forms disclosed, but on the contrary, the inten UnidrV5 color Support has many improvements compared tion is to cover all modifications, alternative constructions to previous drivers. First, UnidrV5 adds support for dithered and equivalents falling within the Spirit and Scope of the text and allows the driver to query the original brush color at DrvTextOut time. This enables UnidrV5 to achieve WYSI invention as defined by the appended claims. WYG effect on text colors, resulting in better text quality. DESCRIPTION OF THE PREFERRED UnidrV5 also has improved halftone support by improving 35 EMBODIMENT the Standard Set of halftone patterns for better output. quality. UnidrV5 also adds Support for custom halftone patterns FIG. 1 and the following discussion are intended to provided by the printer driver. Additionally, UnidrV5 also provide a brief, general description of a Suitable computing Supports custom image processing. UnidrV5 allowS OEM’s environment in which the invention may be implemented. 40 Although not required, the invention will be described in the to plug in Special code for optimized halftone and/or color general context of computer-executable instructions, Such as correction at the backend. UnidrV5 supports ICM2.0 for program modules, being executed by a personal computer. better color output quality. Generally, program modules include routines, programs, BRIEF DESCRIPTION OF THE DRAWINGS objects, components, data structures, etc. that perform par 45 ticular tasks or implement particular abstract data types. FIG. 1 is a simplified block diagram illustrating an Moreover, those skilled in the art will appreciate that the exemplary operating environment Suitable for application of invention may be practiced with other computer System the instant invention; configurations, including hand-held devices, microprocessor FIG. 2 is a simplified block diagram illustrating data flow Systems, microprocessor-based or programmable computer between components of an embodiment of the instant inven 50 electronics, network PCs, minicomputers, mainframe tion; computers, and the like. The invention may also be practiced FIG. 3 is a simplified block diagram illustrating high level and distributed computing environments where tasks are modular interface between the universal printer driver of the performed by remote processing devices that are linked instant invention and the OEM customization modules writ through a communications network. In a distributed com ten in accordance with the GPD of the instant invention; 55 puting environment, program modules may be located in FIG. 4 is a simplified flow diagram illustrating System both local and remote memory Storage devices. operation allowing for built-once-run-always function With reference to FIG. 1, an exemplary system for imple ality; menting the invention includes a general purposed comput ing device in the form of a conventional personal computer FIG. 5 is a simplified data eXchange diagram illustrating 60 20, including a processing unit 21, a System memory 22, and communication between COM components in accordance a System buS 23 that couples various System components with the instant invention; including the System memory to the processing unit 21. The FIG. 6 is a simplified module/function interface diagram System buS 23 may be any of Several types of bus Structures illustrating functional interfaces between elements of the including a memory bus or memory controller, a peripheral instant invention; 65 bus, and a local bus using any of a variety of bus architec FIG. 7 is a UI default document properties illustration as tures. The System memory includes read-only memory generated by a component of the instant invention; (ROM) 24 and random access memory (RAM) 25. A basic US 6,825,941 B1 7 8 input/output System 26 (BIOS), containing the basic routines be appreciated that the network connections shown are that help to transfer information between elements within exemplary and other means of establishing the communica the personal computer 20, Such as during Startup, is Stored in tions link between the computerS may be used. ROM 24. The personal computer 20 further includes a hard Turning now to the Universal Printer Driver (Unidrvis) of disk drive 27 for reading from and writing to a hard disk, not the instant invention, this UnidrV5 allows original equip shown, a magnetic disk drive 28 for reading from or writing ment manufacturers (OEMs) to provide customization com to a removable magnetic disk 29, and an optical disk drive ponents (plugins) to modify the Standard driver user inter 30 for reading from or writing to a removable optical disk 31 face and the output data Stream Sent to the printer. A such as a CD ROM or other optical media. The hard disk simplified view of the data flow between the components of drive 27, magnetic disk drive 28, and optical disk drive 30 the universal printer driver of the instant invention and the are connected to the system bus 23 by a hard disk drive OEM developed generic printer description (GPD) file is interface 32, a magnetic disk drive interface 33, and an illustrated in FIG. 2. As may be seen from this figure, the optical drive interface 34, respectively. The drives and their driver architecture is open, i.e. the OEMs are allowed to asSociated computer-readable media provide nonvolatile plug-in custom functions wherever appropriate. This allows Storage of computer readable instructions, data Structures, 15 this architecture to be very extensible, allowing OEMs to program modules and other date for the personal computer Support new printers and features between additional 20. Although the exemplary environment described herein releases of the universal driver of the instant invention. employs a hard disk, a removable magnetic disk 29 and a Additionally, because most OEM presumably know better removable optical disk 31, it should be appreciated by those how to generate outputs tailored for their specific printers, skilled in the art that other types of computer readable media better graphics and text quality also results, especially for which can Store data that is accessible by the computer, Such inkjet printers. As may be seen from FIG. 2 the driver as magnetic cassettes, flash memory cards, digital Video architecture is modular. This modular driver architecture is disks, Bernoulli cartridges, random access memories composed of multiple well-defined modules based on func (RAMs), read-only memories (ROMs), and the like, may tionality. Any particular printer may use Some or all of these also be used in the exemplary operating environment. 25 modules functionality as desired by the OEM. A number of program modules may be Stored on the hard disk, magnetic disk 29, optical disk 31, ROM 24, or RAM AS may be seen from FIG. 2, the design of the generic 25, including an operating System 35, one or more applica printer description (GPD) file 102 has a significant influence tion programs 36, other program modules 37, and program on the driver's flexibility. A detailed description of the GPD data 38. A user may enter commands and information into format, features, and advantages is included more fully the personal computer 20 through input devices Such as a hereinbelow. The GPD parser 104 parses the textbased GPD keyboard 40 and a pointing device 42. Other input devices file into internal binary data structures 106. The parser 104 (not shown) may include a microphone, joystick, game pad, is called only once when the printer is installed. After that, the driver accesses the cached binary data structures 106 Satellite dish, Scanner, or the like. These and other input unless the GPD file 102 has since been updated. The parser devices are often connected to the processing unit 21 35 through a Serial port interface 46 that is coupled to the 104 also generates helpful error and warning messages for System bus, but may be connected by other interfaces, Such improper GPD files. Note that the GPDfile format continues as a parallel port, game port, or a universal Serial bus (USB). to evolve over time to order to provide new printing func A monitor 47 or other type of display device is also tionality. connected to the System busy 23 via an interface, Such as a 40 The driver user interface (UI) DLL 108 is a separate DLL video adapter 48. In addition to the monitor, personal that handles all device capability/Setting queries and pre computers typical include other peripheral output devices sents the graphical user interface (GUI). This DLL 108 (not shown), Such as speakers and printers. interacts with the user and applications, and it provides the The personal computer 20 may operate in a networked device and document settings 110 for the rendering driver environment using logical connections to one or more 45 112. The support provided by the driver user interface DLL remote computers, Such as a remote computer 49. The of OEM custom UII 14 exists at two different levels. First, remote computer 49 may be another personal computer, a the OEM adds custom items and/or makes minor changes to Server, a router, a network PC, a peer device, or other the standard UI. In this scenario the driver controls the UI common network node, and typically includes many or all of and its overall look and feel. Second, the OEM may replace the elements described above relative to the personal com 50 the functionality of the UI DLL 108 completely for cases puter 20, although only a memory storage device 50 has where the first level of Support cannot accommodate the been illustrated in FIG.1. The logical connections depicted OEM requirements. in FIG. 1 include a local area network (LAN) 51 and a wide The driver rendering control 112 covers all DDI calls and area network (WAN) 52. Such networking environments are font-related calls. The driver rendering DLL's 112 primary commonplace in offices, enterprise-wide computer 55 function is to convert DDI calls into printer-specific data and networks, intranets, and the Internet. send them to the spooler. This DLL 112 also handles When used in a LAN working environment, the personal information queries regarding the device Surface, Such as computer 20 is connected to the local network 51 through a fonts, brushes, colors, etc. network interface or adapter 53. When used in a WAN The control module 116 within the driver rendering DLL networking environment, the personal computer 20 typically 60 112 initializes pdev and Sets up the dispatch for rendering includes a modem 54 or other means for establishing com DDI calls based on the printer's capability. It also handles munications over the y-area network 52, Such as the Internet. banding and dumping raster data to the printer. Both banding The modem 54, which may be internal or external, is and non-banding methods are Supported. connected to the System buS 23 via the Serial port interface Also within the driver rendering DLL 112, a font module 46. In a networked environment, program modules depicted 65 120, and a raster module 122. The font module 120 enu relative to the personal computer 20, or portions thereof, merates device fonts and handles TextOut DDI, including may be stored in the remote memory Storage device. It will downloading true type fonts to the printer. This module 120 US 6,825,941 B1 9 10 will handle interfacing with font downloaders. In 4 bpp ensure seamless compatibility with each other. COM speci mode bitmap fonts should be half-toned as well, i.e. more fies that a client (Unidrviš driver of the instant invention) than eight colors. The driver also Supports gray Scale fonts, communicates with the component (OEM plugins) through including both bitmap fonts and device fonts. The raster an interface, where an interface is a Set of functions that a module 122 handles all bitmap related DDI calls, whether component implements and the clients use. To find out the target is a compatible memory bitmap, or the banding whether a component Supports a specific interface, the client buffer, or the printer's Surface. This module 122 also Sup queries the component for the interface, using an interface identifier, a unique constant that is associated with a specific ports OEM custom half-toning and color correction DLL interface. Conversely, the OEM plugins can use the UnidrV5 interface. It also Supports OEM custom dithering patterns. driver as helper function component. In a preferred embodiment of the instant invention, the AS COM components, OEM plugins are able to encap driver allows for multiple OEM plugin modules as illus Sulate the implementation details of the customization inter trated in FIG. 3. First, the OEM plugin can have an user face. To the UnidrV5 driver of the instant invention, the interface (UI) module 60 which interacts with the UI module OEM plugin is just a set of interfaces. The driver doesndoes 62 of the printer driver 64 of the instant invention. This nott know all the interfaces that the component Supports, module is responsible for UI customization and reporting 15 only the interface OEM plugin publishes for any given device capabilities. Second, the OEM plugin can include an interface identifier. AS OEM customization interfaces OEM rendering module 66 which interacts with the render evolve, these new interfaces will also be Supported, in ing module 62 of the printer driver 64. This module is addition to Supporting old interfaces. This way, multiple responsible for customizing the output data Stream. interfaces allows the Support of new interfaces as well as It is not necessary to have both modules 60, 66 to older interfaces. To comply with COM specification, a new customize a printer; one or both modules can be present interface and interface identifier will be defined as described depending on the needs of the OEM. If, however, multiple herein if any of the following conditions are changed: the OEM plugins are provided for a printer driver 64, it is up to number of functions in an interface; the order/meaning/ the OEM who creates the INF file for the printer to ensure 25 return value/type of return value of any functions in an that these plugins work well with each other. The driver of interface; the number of parameters in a function; and/or the the instant invention calls these modules in a predefined order/types/meaning of the parameters in a function. order described more fully hereinbelow. The driver of the The driver Subsystem of the instant invention can be instant invention Supports up to 16 OEM plugins for each treated as a set of 4 COM components which communicate printer. to each other Solely via interfaces. The first two, as Stated There are several reasons for providing OEMs the capa above, are the Rendering module 68 and the User Interface bility to customize the standard printer driver 64 of the (UI) module 62 of the Unidrv5 driver 64 of the instant instant invention. First, OEMs can provide custom features invention. The last two COM components are the OEM Specific to their printer models that are not specifically supplied Rendering plugin module 66 and the OEM supplied supported by the driver of the instant invention. This 35 User Interface plugin module 60. For simplicity, the follow requires that the OEM present an UI to display the features ing assumes that there is one OEM Supplied UI 60 and and perhaps Sending appropriate data to the printer while Rendering 66 plugin, although the OEM may Supply more printing. Second, printer OEMs can differentiate their print than one or none of each type of plugin. Additional plugins ers by customizing the look and feel of the UI presented to still communicate with the system driver of the instant the user. This may preferably involve complete functionality 40 invention using the same interfaces as the first plugin, and replacement of the standard UI provided by the universal plugins do not communicate among themselves. Therefore, printer driver of the instant invention. Third, OEMs can adding more plugins does not change the manner in which provide a custom help file to Supplement or replace the the interfaces are used. standard driver help content. This is especially helpful for AS will now be apparent to one skilled in the art, the generic features Supported in Generic Printer Description 45 system User Interface 62 and OEM UI 60 plugin modules (GPD) files and for added custom features. If the OEM is communicate via the IPrintOemJI and IPrintOemDriver UI replacing the whole UI functionality, this help file will be interfaces, while the system rendering modules 68 and OEM used by the OEM UI module 60. rendering plugins 66 communicate via the IPrintOem Uni The driver of the instant invention includes functionality and IPrintOemDriverUni interfaces. Additionally, the IPrint to ensure backward and forward compatibility of the OEM 50 Oemluni interface allows the Unidrvis of the instant inven plugins. This feature is known as “build once and run tion to access the methods implemented by the UnidrV5 always.” This functionality ensures that “Older OEM plu OEM plugin rendering module 66. Further, the IPrintOem gins will work with the “Newer' Unidrvis driver of the DriverUni interface allows the UnidrV5 OEM plugin ren instant invention. For example, OEM plugins built for NT5 dering module 66 to access the render mode helper function should work with NT6 (or greater) Unidrv driver. Any 55 services implemented by Unidrv5 64. The IPrintOemUI changes to the customization interface are transparent to interface allows the system UI module 62 to access the OEM plugins. This functionality also ensures that “Newer” methods implemented by the OEM UI plugin module 60. OEM plugins will work with “Older” Unidrvis driver of the Finally, the IPrintOemlDriverUI interface allows the OEM instant invention. For example, OEM plugins built for NT6 UI plugin module 60 to access the UI helper function (or greater) should work with the Unidrviš driver of the 60 services implemented by the system UI module 62. instant invention which is first being implemented in NT5, The OEM must also implement a subset of the COM assuming the OEM plugin Support older customization Class Factory interface. That interface is also defined below. interfaces (i.e. NT5 interface). Each interface consists of a set of Methods or Member In order to fulfill the requirements above, OEM plugins functions, which may be accessed once a pointer to the are preferably Component Object Model (COM) compo 65 interface has been obtained. Not all methods are nents. COM is an industry wide specification Standard, implemented, So components should be able to handle cases providing a Standard for the driver and plugins to follow to where a method returns E NOTIMPL. It is expected that as US 6,825,941 B1 11 12 the System drivers and printer hardware are enhanced, new member functions will be needed and existing functions may become obsolete. AS this occurs, a new interface will be HRESULT DIIGetClassObject( defined in accordance with the teachings of the instant const CLSID &clsid, invention. The System drivers will always Support all pre const IID &id, vious interfaces in addition to the current interface. OEM void **ppv) plugins may choose to Support Some, all or none of the previous interfaces depending on the level of backward clsid: Specifies the class ID of the class factory being compatibility and functionality desired. As shown in FIG. 4. requested. Driver's UI module will pass in CLSID UnidrV5 will always start by querying for the current OEM 1O OEMUI and driver's rendering module will pass in interface 70 and if that is not supported by the OEM plugin CLSID OEMRENDER. The function should return 72, will work backwards, requesting older 74 and older CLASS E CLASSNOTAVAILABLE if clsid does interfaces 76 until one is found 78, 80 that is supported by not match these two CLSIDS defined in NT DDK the OEM plugin 82, 84, 86. An OEM plugin that supports header file. only the original interface is guaranteed to work with any 15 future version of UnidrV5, but it may not be able to take id: Specifies the interface in the class factory with which advantage of features available through the more recent driver wants to talk to, which is always IID interfaces. IClassFactory. For the purposes of version control, each of the types of ppV: Returns pointer to the requested interface interfaces listed above is independent of each other. For (IClassFactory), which will be used by the driver to ask example, assume a new version release (i.e. NT6) Supports the class factory to create plugin components (by new version interfaces: I Print Oem UniG, calling its member function CreateInstance). IPrintOemDriverUnió, IPrintOem UI6, and IPrint OemDriv DllGetClassObject should return S OK if succeeded, and erUI6. The OEM UI module may choose to implement the return appropriate error code (refer to COM specification) original IPrint Oem UI interface while using the enhanced 25 otherwise. IPrintOemDriverUI6 helper functions interface. Similarly OEM plugins must export another function the version of the interfaces used or implemented by the DllCanUnloadNow, which will be called during plugin OEM UI module have no bearing on the version of the unloading by the driver to ask OEM plugin whether it can be interfaces used or implemented by the OEM Rendering unloaded or not. Module. HRESULT DllCanUnloadNow( ) In addition to the core UI/rendering module functionality, In this function, OEM plugin should check whether it is OEM plugins are also responsible for implementing and serving any components. If not, the function should return exposing the class factory. A class factory is a COM com S OK and the plugin will be unloaded by the driver. ponent with a single job: creating other components. To be Otherwise, it should return S FALSE and the plugin will more Specific, a particular class factory creates components 35 not be unloaded. that correspond only to a single, specific CLSID. OEM The above discussion illustrates the need for COM. The plugins first need to define an object that implements the components talk to each other using a known interface. IClassFactory interface and implement its member functions Driver 64 and OEM customization DLL 88 are components as illustrated generally in FIG. 5. Among the member as illustrated in FIG. 5. They are also clients for each other. functions, Createnstance is class factory Specific. 40 So driver 64 is a client for OEM customization component 88 and at the same time OEM customization component 8 is a client for driver 64. They interact with each other using two types of interfaces. The OEM interface is used by the HRESULT CreateInstance( driver of the instant invention to call different OEM cus IUnknown *pUnkOuter, 45 const IID &id, tomization functions. The driver helper function interface is void **ppv) used by the OEM to call driver provided helper functions like Drv WriteSpool Buf. It is recognized that the driver and OEM can have pUnkOuter: Specifies the controlling IUnknown interface different versions. To make Sure that they work together, the of aggregation. Since there is no aggregation, the 50 interaction Starts with establishing a relationship, which function should return CLASS E involves finding out which interface the OEM component NOAGGREGATION if this parameter is not NULL. supports as discussed above and as illustrated in FIG. 5. This id: Specifies the OEM interface driver wants to commu involves getting the class factory interface from the OEM nicate with, which is always IID IUnknown. component 80 and using this interface to get the IUnknown ppV: Returns pointer to the requested interface 55 interface. To do this driver 64 does a GetProcaddress for (IUnknown), which will be used by the driver to query standard COM function DllGetClassObject. If the OEM for the specific OEM interface. component 88 does not export this function, then driver 64 Createnstance should create a new instance of the object assumes that OEM is not supporting COM interface. If this that implements the corresponding OEM interface defined function is exported and driver 64gets an IUnknown, then it by the driver (i.e. IPrintOemUI, IprintOemuni, etc). It 60 uses IUnknown->QueryInterface to query interface. Driver should return S OK if Succeeded, and return appropriate 64 starts asking for highest known interface. If the OEM 88 error code (refer to COM specification) otherwise. component does not know about that interface, it fails the After the class factory is implemented, it needs to be call. Driver 64 then asks for next lower interface and keeps exposed so that the driver will be able to locate the class calling till OEM 88 returns success. Now driver 64 knows factory after it has loaded the OEM plugins. To expose its 65 which interface OEM component 88 Supports. This class factory, OEM plugins must export the function DllCiet approach allows driver 64 to use the highest known OEM ClassObject. interface, So that no functionality is lost. US 6,825,941 B1 13 14 Once the driver finds out about the OEM components DriverFileN entry specifies the OEM rendering module, and interface, it createS IUnknown interface for its own helper OEMConfigFileN entry specifies the OEM UI module. Any function interface. The driver passes IUnknown interface of the two entries can be omitted if the plugin has no pointer to OEM component using Publish DriverInterface corresponding module, but at least one entry must be method of OEM interface. Once OEM gets the IUnknown present. In the following example, there are two OEM interface pointer from driver, it should call IUnknown plugins associated with the driver. Notice that the Second >QueryInterface to find out which helper function interface plugin does not have a user mode UI module. is supported by the driver. The OEM component should also #OEM plugin configuration file for . . . query from highest known interface to lowest known inter face. Driver will return Success for the known interface and OEMFiles) failure if the interface is not known. Now the OEM com OEMDriverFile1 =OEMDRV1.DLL ponent also has the interface pointer of the highest known OEMConfigFile1=OEMUI1.DLL helper function interface. OEM saves this interface in it is OEMDriverFile2=OEMDRV2.DLL own data structure. Now that both driver and OEM have It is important to note that filenames listed in OEMFiles known interfaces, they can then use interface functions to 15 Section must not have any directory prefix. Also, there must call each other. Using this method the driver of the instant not be any spaces before or after the "=" specifier. These files invention can work with any version of the OEM compo will be copied into appropriate System directories during the nent. OEM can also write the component in Such a way that installation process. The driver can determine the full path to it Supports all known driver helper function interfaces. This those directories, which is not trivial in order to point-and will make the OEM DLL “Build Once Run Always.” print to work Smoothly. In COM implementation all the methods have to be The OEM UI 60 module is a 32-bit Dynamic Link Library written, even if they do not do anything. The method (DLL) that runs in user mode and interacts with the normally returns E NOTIMPL if it is not implemented. Microsoft printer driver UI modules as shown in FIG. 6. The This makes the implementation easier but degrades the OEM UI module 60 can modify the standard UI first by performance. The driver has to call the OEMs for every 25 adding nodes to the Standard treeview in the device Settings method of the interface. Unidrvis needs to know whether or and the Advanced dialog in the printing preference UI (see not the OEM implements some methods before it calls the FIG. 8). Additionally, it can modify the standard UI by method. This is needed for appropriate initializations. To adding property Sheet pages to the driver UI. obtain this information ahead of time, UnidrV5 queries the For the UI control, the printer driver UI module interacts OEM component for implemented methods by calling Get with the OEM UI modules 62 through functions, Implemented Method in the OEM interface. GetImplement OEMGetInfo, OEMDevMode, OEMCommon UI, and a call edMethod takes a method name as a parameter. If a given back function for processing printer properties and docu method is implemented the OEM component returns S OK ment properties callback messages. The OEMGetInfo func otherwise it returns S FALSE. Unidrvis caches this infor tion is called by the driver when the OEM module is loaded mation and calls only the implemented methods. 35 to get the Signature or version of the plugin. It is defined as Once the job is done, the driver of the instant invention follows: releases the OEM interface by calling Release method. It then does a GetProcAddress on standard COM function DllCanUnloadNow and calls it. This function must be HRESULT exported by the OEM component. OEM should release any 40 GetInfo( driver interface at this time and all the memory allocated for IN DWORD dwMode, an interface. If the OEM has no more instances of its OUT PVOID pBuffer, interface DllCanUnloadNow returns S OK and driver IN DWORD cbSize, unloads the OEMDLL. If all the instances of OEM interface OUT PDWORD pcbNeeded ); are not released, then this function returns failure and OEM 45 DLL is not unloaded. OEM plugins are installed in the System as Special depen dwMode: Identify the query type. It can be any of the dent files of the printer driver. They are preferably listed in following values: the CopyFiles entry of printer driver's INF file. One of the OEMGI GETSIGNATURE dependent files is preferably a configuration file with INI 50 OEMGI GETVERSION filename extension. Its purpose is to help to identify other pBuffer: Pointer to output buffer which holds the return dependent files. The INI file can be either an ANSI or a data. Unicode text file. It is recommended that Unicode text file cbSize: Specifies the size of the buffer pointed by pBuffer. be used to avoid potential localization problems. (Notepad pcbNeeded: Pointer to a DWORD. Returns the number of can save text file in Unicode format.) The INI filename 55 bytes written into the output buffer by the OEM plugin. should be specific enough to avoid conflicts with INI files If the output buffer is not large enough, OEM plugin from other OEMs. The format of an INI file is defined as: should return FALSE and set the error code to Section ERROR INSUFFICIENT BUFFER. In that case, key=value this variable returns the size of the expected output 60 buffer. Currently, only OEMFiles section is meaningful to the Return Value: driver. Entries outside of OEMFiles section are ignored. S OK if the function Succeeds, E FAIL if it fails. The Lines Starting with if character are treated as comments. reason for the failure should be set via SetLastError. Each OEM plugin can have up to two entries in the INI GetInfo(OEMGI GETSIGNATURE) is used to get the file: OEMDriverFileN, and OEMConfigFileN, where N is a 65 4-byte OEM signature. This signature is used by the driver number from 1 upward. When multiple OEM plugins are to uniquely identify the OEM plugin and its private dev present, they are called in the order of increasing N. OEM mode information. So it should be chosen with care in order US 6,825,941 B1 15 16 to avoid conflict with other OEM plugins. Zero is not allowed to be used as a signature. Small integers should be -continued avoided as well. One Scheme is to use a four-character DWORD cbBufSize: abbreviation which is relevant to a particular company OEMDMPARAM, POEMDMPARAM: and/or products. If multiple OEM plugins use the same signature, only the first plugin will be loaded. OEMGetInfo (OEMGI GETVERSION) is used to get OEM plugin’s cbSize: Size of OEMDMPARAM structure. version number. Same Signature and version information pdriverobi: Reference pointer to driver's data Structure. should also be used in OEM DMEXTRAHEADER Struc This is used to call ture described below. 1O DrvCetDriverSetting. Devmode support is required only if the OEM plugin In rendering module, it is the same as pdevob. In UI needs a private devmode. The OEM plugins can store their module, it is the poemuiob. own private data in the devmode. The overall structure of the hPrinter: Handle to the current printer. devmode 90 is as shown in FIG. 9. Note that to the 15 hModule: Instance handle to the OEM plugin DLL. application and the Spooler, all of the extra data appears to pPublicDMIn: Pointer to input public devmode. be owned by driver. pPublicDMOut: Pointer to output public devmode. OEM private devmode must always start with the follow pOEMDMIn: Pointer to input OEM private devmode. ing structure 92 as illustrated in FIG. 10. pOEMDMOut: Pointer to output OEM private devmode. cbBufSize: Size of output OEM private devmode buffer. Return value: typedef struct OEM DMEXTRAHEADER { S OK if the function Succeeds, E FAIL if it fails, or DWORD dwSize: E NOTIMPL if it is not implemented. DWORD dwSignature; E FAIL return value from OEM plugin causes the DWORD dwVersion: 25 driver to fail its current entry point and return error OEM DMEXTRAHEADER, *POEM DMEXTRAHEADER: to its caller (e.g. spooler or GDI). Specifically, OEM plugin should not return E FAIL just because the dwSize: Size of OEM private devmode in bytes, including input devmode is invalid. It should take what valid the header itself. information from the input devmode and use appro priate defaults for invalid fields. dwSignature: OEM plugin Signature. An OEM plugin should be very careful when accessing dwVersion: OEM plugin version number. devmode fields, either public or private. It must take into An OEM plugin is called to get the size of its private consideration of different versions of devmode. Devmode DEVMODE, initialize its private DEVMODE with default may grow by adding new fields to the end for both public values, convert an arbitrary version DEVMODE to its 35 and private parts. An OEM plugin must be able to handle current version private DEVMODE, and validate an existing older Smaller devmode by verifying the validity of a field OEM private DEVMODE and merge the information into an before accessing it, and handle future bigger devmode by output devmode. recognizing that the size may grow. For the most part, this All of these happen through the DevMode function: has already been taken care of by the driver. Except for 40 OEMDM CONVERT, the driver will provide OEM plugin with its current version DEVMODE. Conceptually, the driver goes through the following Steps HRESULT upon receiving an arbitrary input devmode. First, it calls DevMode( IN DWORD dwMode, DevMode(OEMDM SIZE) to get the size of OEM private POEMDMPARAM pOemDMParam 45 devmode, allocates enough memory, and calls devMode (OEMDM DEFAULT) to let OEM plugin provide its default devmode settings. Second, it then calls DevMode (OEMDM CONVERT), with the default OEM private dev dwMode: One of the following constants (more details on mode allocated in the previous step in p0EMDMOut in case these later): 50 it is needed. OEM plugin must be prepared to deal with the OEMDM SIZE fact that the input OEM private devmode may be from an OEMDM DEFAULT older or a new version of the OEM plugin. If it is the same OEMDM CONVERT version, then it can simply copy the input devmode to the OEMDM MERGE output buffer. Third, the converted OEM private devmode is pOemDMParam: pointer to OEMDMPARAM structure 55 finally merged with the printer's default devmode informa defined as following. tion. (Set through “Printing Preferences . . . " menu item from the “Printers” folder.) The driver calls DevMode (OEMDM MERGE) with the printer default devmode as output and the converted devmode from Step 2 as input. It is typedef struct OEMDMPARAM { DWORD cbSize: 60 important to note that an OEM plugin should never assume PVOID pdriverobi: that it can locate its extra data from the top of the public HANDLE hPrinter; devmode. All access to its private devmode data must HANDLE hModule: happen through poEMDMIn and pCEMDMOut. PDEVMODE pPublicDMIn: PDEVMODE pPublicDMOut: To get the size of an OEM plugin’s private devmode, the PVOID pOEMDMIn; 65 driver calls DevMode with the dwMode field set to PVOID pOEMDMOut: OEMDM SIZE. OEM plugin should put the size required for its private devmode data in the cb BufSize field 94 of US 6,825,941 B1 17 18 OEMDMPARAM structure and return TRUE to indicate newer or current version of the same OEM plugin. An OEM success as illustrated in FIG. 11. If an OEM plugin does not plugin converts this to the current format retaining as much need a private devmode, it should not implement DevMode information as possible, and copies it to the output buffer function from its DLL. pOEMDMOut 98. OEM plugin should not access any bytes beyond (PBYTE) p0EMDMIn+poEMDMIn->dwSize. Some caution should be exercised as well when accessing fields in pPublicDMIn 100. Field In Out The driver calls Dev Mode with dwMode set to CbSize sizeof (OEMDMPARAM) OEMDM MERGE to request an OEM plugin to validate Pdriverobi Reference to driver's data structure - the information in the input private devmode and merge it HPrinter Handle to the current printer HModule Handle to OEM plugin DLL with the default private devmode, placing the result in the PPublicDMI NULL output buffer (pOEMDMOut) 98 as illustrated in FIG. 13. PPublicDMOut NULL OEM plugin can assume both pOEMDMIn 96 and pCEM POEMDMI NULL DMOut 98 point to its version devmodes, although pCEM POEMDMOut NULL 15 CbBufSize O size of OEM DMIn may contain invalid information. private devmode

To fill the OEM private devmode with default values, the Field In Out driver calls DevMode with dwMode set to OEMDM CbSize sizeof(OEM DEVMODEPARAM) - DEFAULT. Pdriverobi Reference to driver's data structure - HPrinter Handle of Printer HModule Handle of OEM module PPublicDMIn Points to input public devmode Field In Out PPublicDMOut Points to output public devmode 25 POEMDMIn Points to input OEM private CbSize sizeof devmode, containing information (OEM DEVMODEPAPAM) returned from OEMDewMode Pdriverobi Reference to driver's data structure - (OEMDM CONVERT) HPrinter Handle of Printer POEMDMOut Points to output OEM private OEM plugin HModule Handle to OEM plugin DLL devmode, containing valid current should merge any PPublicDMIn Points to input public DEVMODE - version OEM private settings. valid information containing default values set by the from the input driver devmode into the PPublicDMOut NULL output devmode. POEMDMI NULL CbBufSize size of OEM private devmode pOEMDMOut Pointer to output OEM private OEM plugin should devmode buffer fill the output buffer 35 with its default The driver allows OEM plugins to access and update private devmode driver's private settings through DrvOetDriverSetting and settings. DrvUpdate UISetting and Drv Upgrade RegistrySetting cbBufSize size of OEM private devmode helper functions. OEM plugins can obtain the address of these helper functions in the driver's helper function The driver calls Dev Mode with dwMode set to 40 interface, IPrint OemDriverUI. OEMDM CONVERT to request an OEM plugin to convert DrvGetDriverSetting helper function allows the OEM its private devmode to the current version (without plugins to access the driver's private Setting. validation) as illustrated in FIG. 12. 45 HRESULT Field In Out DrvCietDriverSetting PVOID pdriverobi, CbSize sizeof (OEM DEVMODEPARAM) - PCSTR Feature, Pdriverobi Reference to driver's data structure - PVOID pOutput, HPrinter Handle to the current printer 50 DWORD cbSize, HModule Handle to OEM plugin DLL PDWORD pcbNeeded, PPublicDMIn Pointer to input public devmode PDWORD pdwOptionsReturned PPublicDMOut Pointer to output public devmode, ); containing information which the driver has already converted from the input devmode 55 pdriverobi: Reference pointer to driver's data Structure. POEMDMIn Pointer to input OEM private devmode to be converted Feature: Specifies what feature the caller is interested in. POEMDMOut Pointer to output OEM private OEM plugin pOutput: Points to output buffer. devmode buffer, containing the should convert default current version OEM private the input dev cbSize: Specifies the size of the output buffer. devmode information mode and stores pcbNeeded: Returns the minimum size for the output the result in the 60 output devmode buffer. buffer. pdwOptionsPeturned: Returns the number of options cur CbBufSize size of current version OEM private - rently Selected for the Specified feature. devmode Feature specifies the name of the feature in which the 65 caller is interested. The name must be an ANSI string As Windows NT supports printer connections over the containing only printable ASCII characters. The name network, p0EMDMIn 96 could point to data from older, should come from the printer description file. For generic US 6,825,941 B1 19 20 printer features, the output buffer will return the name(s) of currently selected option(s). The output will be in the MULTI SZ form, i.e. a sequence of nul-terminated ASCII HRESULT character Strings followed by an extra nul-character at the DrvUpgradeRegistrySetting end. 5 HANDLE hPrinter, If the value of Feature is less than OX10000, then Feature PCSTR pFeature, refers to one of the predefined driver features. For a list of PCSTR pOption predefined driver feature indices, refer to OEMGDS constants defined in printoem.h. Index values from 1 to 0x7ff refer to document-sticky settings in the current dev hPrinter: Handle to printer driver module. mode. Index values from 0x8000 to 0xffff refer to printer pFeature: Pointer to FEATURE keyword name to Sticky Settings in the registry. For predefined driver features, upgrade. the meaning of output value varies. pOption: Pointer to OPTION keyword name to upgrade. To determine how big the output buffer should be, 15 The driver will use the (pFeature, p0ption) pair to DrvOetDriverSetting should be first called with pCutput set upgrade its internal data to the requested Settings. to NULL and cbSize set to 0. DrvOetDriverSetting will Return Value return E FAIL in this case and the last error code will be set S OK if the function Succeeds, E FAIL if it fails, or to ERROR INSUFFICIENT BUFFER E NOTIMPL if it's not implemented. In most situations, an output buffer size of 64 bytes should OEM plugins can add, replace or hide nodes in the be big enough. So OEM plugins may want to start out with treeview display on the device settings UI or the Printing a buffer of this size to avoid having to call DrvOetDriver Preferences UI. To accomplish this, an OEM plugin should Setting twice. implement the Common UIProp function. The driver calls Return Value CommonuIProp to give OEM plugin a chance to add its UI 25 S OK if the function Succeeds, E FAIL if it fails, or items after the driver's items. An OEM plugin can also E NOTIMPL if it is not implemented modify the driver's items at this point. The driver first calls this function to get the number of OPTITEMs that the OEM DrvUpdateUISetting helper function allows the OEM wishes to add, allocates the required memory for plugins to update the driver's UI Settings and ShowS UI OPTITEMs, and calls this function again for the OEM to constraints, if applicable. This function is valid only while provide the OPTITEMs. Note that any memory required to the UI is present. fill out the OPTITEMs, such as OPTTYPEs and OPTPARAMs, can be allocated by the OEM from the memory heap Supplied by the driver. The driver is respon HRESULT Sible for disposing the heap when the items are no longer DrvUpdateUISetting( 35 needed. The behavior is the same for both DocumentProp PVOID pdriverobi, ertySheets items and PrinterPropertySheets items. PVOID pOptItem, DWORD dwPreviousSelection, DWORD dwMode 40 HRESULT Common UIProp( DWORD dwMode, pdriverobi: Reference pointer to driver's data Structure. POEMCUPPARAM pOemcUIPParam pOpttem: Specifies the OPTITEM that contains the infor mation to be updated in driver's Settings. 45 dwPreviousSelection: Specifies the previous selection of dwMode: one of the following values. the OPTITEM. This selection is used to restore the UI OEMCUIP DOCPROP This function is called from Setting to the previous Selection once a contraints is DrvDocumentPropertySheets found with the new selection and the user wishes to OEMCUIP PRNPROP This function is called from cancel the Selection. 50 DrvDevicePropertySheets dwMode: Specifies the document property mode or pOemCUIPParam: pointer to OEMCUIPPARAM struc device property mode. ture defined below. OEMCUIP DOCPROP This function is called from DrvDocumentPropertySheets 55 OEMCUIP PRNPROP This function is called from typedef struct OEMCUIPPARAM { DrvDevicePropertySheets DWORD cbSize: Return Value POEMUIOBJ poemuiobi; HANDLE hPrinter; S OK if the function Succeeds, E FAIL if it fails, or PWSTR pPrinterName: HANDLE hModule: E NOTIMPL if it's not implemented. 60 HANDLE hOEMHeap; The OEM plugin calls this helper function to upgrade PDEVMODE pPublicDM: their device Settings Stored in private registry keys into the PVOID pOEMDM: DWORD dwFlags; driver's internal private data. This function is needed only if POPTITEM pDrvOptItems; the OEM, in previous driver version, had stored device DWORD cDrvOptItems: settings, which are now part of the GPD file, in private 65 POPTITEM poEMOptItems: registry keys. This is necessary and valid only when called DWORD coEMOptItems; from OEM’s Upgrade Printer function. US 6,825,941 B1 21 22 -continued -continued Field In Out PVOID pOEMUserData; OEMUICALLBACK OEMUICallback; HPrinter Handle to the current printer OEMCUIPPARAM, POEMCUIPPARAM: PPrinterName Name of the current printer HOEMHeap Handle to OEM memory heap PpublicDM Pointer to public DEVMODE POEMDM Pointer to OEM private devmode - cbSize: Size of OEMCUIPPARAM Structure. DwFlags fMode passed in for poemuiobi: Reference pointer to driver's data Structure; DrvDocumentProperty Sheets call used to call DrvOetDriverSetting. PDrvOptItems Points to driver's OPTITEMs CDrvOptItems Count of driver's OPTITEMs hPrinter: Handle to the current printer. POEMOptitems Points to OEMs OPTITEMs Filled out buffer OPTITEMs pPrinterName: Name of the current printer. COEMOptItems count of OEM OPTTEMS hModule: Instance handle to OEM plugin DLL. POEMUserData NULL pointer to OEM 15 private data hOEMHeap: Handle to a memory heap from which OEM OEMCUIPCaback NULL address of plugin should allocate all of its memory. OEM UI call pPublicDM: Points to public devmode. back function pOEMDM: Points to OEM private devmode. dwFlags: the fMode parameter passed in for either Drv pOEMUserData field should return a pointer to OEM DocumentProperty Sheets or DrvDevice Property plugin’s private data Structure. Later during callbacks, the Sheets. driver will give OEM plugin a pointer to this same OEM CUIPPARAM structure. OEM plugin can easily obtain a pDrvOptitems: Points to driver's UI items (array of pointer to its private data from there. If dwMode is OPTITEMs). OEMCUIP PRNPROP, there will be no devmode informa cDrvOptitems: Count of driver's UI items. 25 tion and both pPublicDM and pOEMDM will be NULL. pOEMOptItems: Points to OEM plugin’s UI items. cCEMOptItems: Count of OEM plugin’s UI items. pOEMUserData: Points to OEM plugin’s private data. typedef LONG (APIENTRY *OEMCUIPCALLBACK)( OEMUICallback: Address of OEM plugin’s UI callback PCPSUICBPARAM pCallbackParam, function. POEMCUIPPARAM pOemCUIPParam Return Value S OK if the function Succeeds, E FAIL if it fails, or During dialog processing, COMPSTUI normally calls the E NOTIMPL if it's not implemented. 35 driver to process messages for node items. For example, the The table below Summarizes the contents of the OEM driver gets called by compStui when there is a Selection CUIPPARAM structure for the first call to get OEM plugin’s change or when the user presses OK or Cancel. The driver OPTITEM count: (Although this example is for first processes the message itself and then calls each OEM OEMCUIP DOCPROP, it is very similar for OEMCUIP plugin to give them a chance to process the message as well. PRNPROP) 40 In addition to PCPSUICBPARAM pointer from COMPSTUI, the driver passes an additional parameter to OEM plugin’s callback function. This is a pointer to the same OEMCUIPPARAM structure that the driver passed to Field In Out CommonuIProp earlier. CbSize sizeof(OEMCUIPPARAM) 45 Given OEMCUIPPARAM, OEM plugin can easily deter Poemuiobi Reference to driver's data structure - HPrinter Handle to the current printer mine whether a particular item p0ptitem belongs to it: PPrinterName Name of the current printer pOptItemd=pOemCUIPParam->pOEMOptItems &&. HOEMHeap Handle to OEM memory heap PPublicDM Pointer to public DEVMODE p Opt Item - POEMDM Pointer to OEM private devmode - pOemCUIPParam->p OEMOptItems

cCEMOptItems DrvDocumentProperty Sheets call If OEM plugin does not care about a particular message PDrvOptItems NULL CDrvOptItems Expected count of driver's (e.g. if the message was meant for a UI item belonging to OPTITEMs some other component), it should return CPSUICB POEMOptItems NULL ACTION NONE from its callback function. Otherwise, it COEMOptItems O count of OEM 55 should process the message and return an appropriate result OPTITEMs POEMUserData NULL value. Result values from different components (the driver OEMCUIPCallback NULL and OEM plugins) are combined as follows: 1. If the callback reason is CPSUICB REASON APPLYNOW: The second call asks the OEM plugin to actually fill out 60 its OPTITEMS: AS Soon as one of the components returns CPSUICB ACTION NO APPLY EXIT, the driver returns that result value to compStui. Otherwise, the Field In Out result value must be CPSUICB ACTION ITEMS APPLIED CbSize sizeof(OEMCUIPPARAM) 65 Poemuiobi Reference to driver's data structure - 2. Otherwise, the precedence for different result values is defined as (in decreasing order): US 6,825,941 B1 23 24 CPSUICB ACTION REINIT ITEMS driver's DrvDevicePropertySheets entry point. (Please CPSUICB ACTION OPTIF CHANGED refer to Windows NT DDK documentation and wind diui.h for more information about these driver entry CPSUICB ACTION NONE points.) FIG. 14 illustrates what happens during a callback when It should be noted that an OEM DLL should not access an item Selection changes. pPublicDM and pCEMDM fields in DevicePropertySheets An OEM plugin may add its own property sheet pages to call. existing property sheet pages provided by the Spooler and An OEM plugin can also optionally implement the fol driver. This is accomplished by the two functions described lowing functions. These functions have almost the same below. If an OEM plugin does not have its own property prototype as their equivalent DDI entry points exported by sheet pages, then it should not implement these functions. the driver. OEM plugins that do not want to handle any of the following functions should not implement them from their DLLs. HRESULT The DevOueryPrintEx function allows the spooler to DocumentPropertySheets( manage mismatched jobs. The driver first checks if the job PPROPSHEETUI INFO pPSUIInfo, 15 is printable or not based on the input devmode information LPARAM Param and the printer Settings in the registry. If it is not printable, ); it returns to the Spooler with an appropriate error message. HRESULT DevicePropertySheets( If it believes that the job is printable, it then calls OEM PPROPSHEETUI INFO pPSUIInfo, plugins DevOueryPrintEx functions. Ajob is printable only LPARAM Param if the driver and all OEM plugins believe that it is printable. If multiple OEM plugins are present, the driver calls them in order until one of them reports that the job is unprintable or Note: The driver will always add its own pages before all of them agree that it is printable. calling compStui to add OEM pages. The control flow is as follows: 25 1. Application calls spooler's DocumentProperties API. HRESULT DevOueryPrintEx( 2. Spooler adds its pages and tells compStui to call the IN POEMUIOBJ poemuiobi, driver's DrvDocumentPropertySheets entry point. IN PDEVOUERYPRINT INFO pDQPInfo, 3. compStui calls the driver which adds its own pages and IN PDEVMODE pPublicDM, asks compStuito call OEM’s DocumentPropertySheets IN PVOID pOEMDM function. 4. compStui calls OEM plugin’s DocumentPropertySheets function. poemuiobj: Reference pointer to driver's data Structure; When multiple OEM plugins are present, the driver adds 35 used to call DrvOetDriverSetting. it pages, and then calls each OEM DLL in turn (through pDQPInfo: Same as what the spooler passed to the compStui). driver's DevOueryPrintEx entry point. The driver passes an OEMUIPSPARAM structure as a pPublic DM: Points to public devmode structure. parameter to each OEM plugin’s DocumentPropertySheets pOEMDM: Points to OEM plugin’s private devmode, and DevicePropertySheets functions. To get a pointer to this 40 if any. parameter, an OEM plugin should do the following at the Return Value beginning of DocumentPropertySheets or DeviceProperty S OK if the function Succeeds, E FAIL if it fails, or Sheets: E NOTIMPL if it's not implemented. p Oem UIPS Param = (POEMUIPS PARAM) This function reports the capabilities of the device. When pPSUIInfo->lParamInit; 45 the driver is called through its DeviceCapabilities entry OEMUIPSPARAM is defined as following: point, it validates the input devmode information, processes the request, and Stores information in the output buffer if applicable. The driver then calls each OEM plugin’s Device Capabilities function. DeviceCapabilities gets the same typedef struct OEMUIPSPARAM { DWORD cbSize: 50 information as what the driver got from DeviceCapabilities POEMUIOBJ poemuiobi; with a couple of exceptions: 1) OEM plugin gets pointers to HANDLE hPrinter; both public devmode and to its private devmode. 2) OEM PWSTR pPrinterName: plugin gets an additional parameter which is the return value HANDLE hModule: HANDLE hOEMHeap; from its previous plugin. The first plugin get the return value PDEVMODE pPublicDM: 55 from the driver itself. PVOID pOEMDM: To ensure harmonious cooperation between the driver and PVOID pOEMUserData; possibly multiple OEM plugins, OEM plugins must follow DWORD dwFlags; the following guidelines in their DeviceCapabilities imple OEMUIPSPARAM, POEMUIPSPARAM: mentations. If an OEM plugin does not Support the device 60 capabilities in question, it should simply return the input The meaning of each field is the same as in OEMCUIP result value and leave everything else untouched. If an OEM PARAM structure except for dwflags: plugin wants to completely handle a particular device For DocumentPropertySheets call, dwflags is the DOCU capability, it should overwrite any existing information in MENTPROPERTYHEADER.fMode value passed into the output buffer and return an appropriate result value. If the driver's DrvDocumentPropertySheets entry point. 65 any errors occur in the process, it should return For DevicePropertySheets call, dwFlags is the DEVICE GDI ERROR as the result value. If an OEM plugin wants PROPERTYHEADER.Flags value passed into the tO US 6,825,941 B1 25 26 modify the output information for a device capability that's Spooler has detected changes in the cache from a printer already handled by the driver or another plugin, it should Server. The driver always processes the events first and then update the output buffer and return an appropriate result calls OEM plugins PrinterEvent functions for further pro value. cessing. Note that if the input result value is GDI ERROR, there is no way for an OEM plugin to determine whether earlier components had an error or they simply didn't Support the HRESULT particular device capability. PrinterEvent.( PWSTR pPrinterName, INT iDriverEvent, DWORD dwFlags, HRESULT LPARAM Param DeviceCapabilities.( ); IN POEMUIOBJ poemuiobi, IN HANDLE hPrinter, IN PWSTR pDeviceName, 15 pPrinterName: IN WORD woapability, iDriverEvent: OUT PVOID pOutput, IN PDEVMODE pPublicDM, dwFlags: IN PVOID pOEMDM, lParam: Same as what spooler passed to the driver's INDWORD dwOld DrvPrinterEvent entry point. IN DWORD dwResult ); Return Value S OK if the function Succeeds, E FAIL if it fails, or E NOTIMPL if it's not implemented. poemuiobi: Reference pointer to driver's data Structure; This API is used to get information about the default color used to call DrvOetDriverSetting. profile for a given devmode, to be used with ICM. hPrinter: 25 pDeviceName: wCapability: HRESULT pOutput: These parameters are identical to what Spooler Query ColorProfile( passed to the driver's DeviceCapabilities entry point. HANDLE hPrinter, PDEVMODEW pdevmode, pPublicDM: Points to public devmode structure. ULONG ulReserved, pOEMDM: Points to OEM plugin’s private devmode. VOID ipvProfileData, ULONG *pcbProfileData, dwOld: Return value from the previous plugin. In the case FLONG *pfiProfileData of the first OEM plugin, this is the return value from the ); driver itself. 35 dwResult: Return value for DeviceCapabilities. hPrinter: Handle to printer driver module. Return Value pdevmode: Pointer to DEVMODE. S OK if the function Succeeds, E FAIL if it fails, or E NOTIMPL if it's not implemented. ulReserved: Reserved. This API gives the driver a chance during the upgrade 40 pVProfileData: Pointer to store color profile data. If this is process to update its device Settings Stored in the registry NULL, the OEM plugin should set the necessary size from one version to the next. This function is needed only if in cbProfileData. any new registry information needs to be added or old pcbProfileData: Pointer to size of pvProfileData buffer in information needs to be validated or updated. The driver UI byte and Store Size of color profile data written to module always processes its own upgrade first and then calls 45 pVProfileData on return. OEM plugins UpgradePrinter functions. pflProfileData: Pointer to store color profile data type. QCP PROFILEMEMORY-The pv ProfileData points to the color profile data itself. QCP PROFILEDISK-The pvProfileData points to HRESULT 50 the color profile name in Unicode. UpgradePrinter( Return Value DWORD dwLevel, PBYTE pDriverUpgradeInfo S OK if the function Succeeds, E FAIL if it fails, or E NOTIMPL if it's not implemented. The FontInstallerDlgProc function is the call back func 55 dwevel: tion handling the UI shown by the font installer. pDriverUpgradeInfo: Same as what's passed into the driver's DrvUpgrade Printer entry point. Currently, dwLevel is always 1 and pdriverUpgradeInfo is a HRESULT FontInstallerDigProc( pointer to an DRIVER UPGRADE INFO 1 struc 60 HWND hWind, ture. UINT usMsg, Return Value WORD wParam, S OK if the function Succeeds, E FAIL if it fails, or LONG Param E NOTIMPL if it's not implemented. ); This API is called when certain events occur that might 65 require action by the printer driver. For example, the driver The parameters above are similar to ones defined for a UI is notified when a local printer is installed or when the dialog procedure defined in the SDK. When it is called with US 6,825,941 B1 27 28 the WM INIT message, or the WM USER+WM FI Following DDI entry points can be hooked out by the NAME message, IPram points to an OEMFONTINSTAP OEM: RAM structure. INDEX DrVRealizeBrush Return Value S OK if the function Succeeds, E FAIL if it fails, or I NDEX DrVDitherColor E NOTIMPL if it's not implemented. I NDEX DrvcopyBits The UpdateExternalFonts function is called by the driver I NDEX DrvBitBlt UI module to update the set of cartridge fonts in the font file. I DEX DrvStretchBlt I DEX DrvStretchBltROP 1O I DEX DrvPlgBlt HRESULT UpdateExternalFonts ( I DEX Drv Alphablend HANDLE hPrinter, HANDLE hHeap, I DEX DrvOradientFill PWSTR pwstrCartridges I DEX DrvTransparentBlt 15 I DEX DrvTextOut PWStrCartridges Specifies the list of cartridges currently I DEX DrvStroke Path installed on the printer, and the font installer should make I DEX DrvillPath Sure only cartridge fonts belonging to these cartridges are in I DEX DrvStroke And FillPath the font file. To add fonts belonging to cartridges not in the I DEX DrvPaint font file, the font installer uses the font file specified by the “ExtFontCartFile’ name in the registry. I DEX DrvineTo Return Value I DEX DrvStartPage S OK if the function Succeeds, E FAIL if it fails, or I DEX DrvSendPage E NOTIMPL if it's not implemented. I DEX DrvEscape Preferably, the driver rendering module interacts with the 25 OEM rendering module DLLs. The OEMDLLs may request I DEX DrvStartDoc direct access to DDI calls, or rely on callbacks from the I DEX Drvendoc driver for Special processing at predefined points during the I DEX DrvStartBanding driver's output generation. It is important to note that the I DEX DrvNextBand OEM rendering module DLLs must not have any global I variables. The OEM rendering module DLL are required to DEX DrvOuery Font support the following function in addition to GetInfo I DEX DrvoueryFontTree described above: I DEX DrvOuery FontData Publish DriverInterface I NDEX Drvouery AdvanceWidths GetImplemented Method 35 I NDEX DrvFontManagement When multiple OEM plugins are present, the same func INDEX DrvoietGlyphMode tion from each OEM DLL is called in turn except for If multiple OEM rendering module DLLs are present, the UNIDRV-only callback functions which allow at most one driver calls them in order. Any DDI function can only be OEMDLL to hook out for each function. The order in which hooked out by at most one OEM DLL. So if Subsequent they are called is determined through the mechanism 40 OEM DLLs try to hook out the same function, they will be described above. ignored. Most of the interfaces between the system driver The driver calls this function during DrvEnablePDEV and the OEM DLL have a PDEVOBJ parameter. In some time to determine which functions the OEM DLL provides cases, this parameter is directly passed to the OEM DLL by and which DDI functions OEM DLL wants to hook out. the driver. In the case of DDI entry points hooked out by the 45 OEM DLL, the OEM DLL can obtain this PDEVOBJ parameter from the SURFOBJ pointer as follows: pdevobj=(PDEVOBJ) pso->dhpdev; HRESULT EnableDriver( DEVOBJ structure is defined as: DWORD dwOem IntfVersion, 50 DWORD cbSize, PDRVENABLEDATA pded ); typedef PVOID PDEVOEM: typedef struct DEVOBJ { DWORD dwSize: dwOemIntfVersion: specifies the OEM interface version 55 PDEVOEM pdevOEM: number used by the driver. HANDLE hEngine; HANDLE hPrinter; cbSize: size of the buffer pointed to by pded, in bytes. HANDLE hOEM; pded: pointer to a DRVENABLEDATA structure used by PDEVMODE pPublicDM: PVOID pOEMDM: OEM DLL to return output data to the driver. PDRVPROCS pDrvProcs: pded->iDriver Version should be the same as Driver 60 Version parameter. pded-->c specifies the number of } DEVOBJ, PDEVOBJ; DDI entry points the OEM DLL has hooked out. pded-spdrVfn points to a function table containing the dwSize: size of DEVOBJ structure. As the customization address of hooked DDI entry points. interface evolves, this Structure may grow. Return Value 65 pdevOEM: pointer to OEM DLL's device data structure. S OK if the function Succeeds, E FAIL if it fails, or This value is returned to the driver by the OEM DLL E NOTIMPL if it's not implemented. during OEMEnablePDEV call. It can be used by the US 6,825,941 B1 29 30 OEM DLL whichever way it sees fit (e.g. a pointer to DisablePDEV function to allow the OEM to free any Some piece of memory). memory associated with its PDEV. The OEM DLL should hEngine: handle used by GDI to identify the current free resources allocated for the PDEV. printer device. This parameter is passed into the driver by GDI during DrvEnablePDEV. hPrinter: Spooler handle to the current printer. It is passed HRESULT into the driver during DrvEnablePDEV. ResetPDEV( PDEVOBJ pdevobjOld, hOEM: instance handle to the OEM plugin DLL. It is PDEVOBJ pdevobjNew obtained when the driver loads the OEM DLL. ); pPublicDM: pointer to public devmode associated with the current device. poEMDM: pointer to OEM DLL's ResetPDEV transfers the state of the driver from the old private devmode, if any. PDEVOBJ to the new PDEVOBJ when an application calls pDrvProcs: Pointer to a table of helper functions provided ResetDC. by the system driver. 15 Details provided later in this section. Before the driver returns its PDEV to GDI, it calls the HRESULT OEM DLL's Enable PDEV to allow it to construct its own DisableDriver( PDEV. At this time, the driver also passes a function table VOID which contains its own implementation of DDI entry points. ); This allows the OEM DLL to pre or post process the parameters and use the driver function to achieve the func If Enable Driver is implemented, the driver will call Dis tionality. The return value from Enable PDEV is passed back able Driver to notify the OEM DLL that it is no longer to the OEM DLL on Subsequent calls as DEVOBJ.pde required and is ready to be unloaded. The OEM DLL should vOEM parameter. 25 free all resources, and get prepared to be unloaded. If the OEM UI DLL adds private data to the DEVMODE Structure, it must provide a rendering module version of the HRESULT DevMode function described herein. The driver uses this at EnablePDEV( print time to validate, convert and generate default DEV PDEVOBJ pdevobi, PWSTR pPrinterName, MODEs as necessary. This function should be identical to ULONG cPatterns, the one provided by the OEM UI DLL, as described herein. HSURF *phsurfPatterns, This code can be implemented in a library and Statically ULONG cGdi.Info, linked to the OEM UI modules and rendering modules. GDINFO *pGdi.Info, The GetInfo function should be provided by the OEM ULONG cDevInfo, 35 DEVINFO *pDevInfo, rendering module DLL, and should be identical to the one DRVENABLEDATA *pded provided by the OEM UI DLL as described above. This can PDEVOEM *pDevOem also be implemented as part of a library as mentioned above ); for DevMode. The Publish DriverInterface function provides a method 40 for the driver to publish its helper function interface. The p de v obj: pointer to a DEVOBJ structure. driver calls the OEM plugin’s Publish DriverInterface func pdevobj->pdevOEM is undefined. tion with the IPrintOemDriver Uni interface which the OEM pPrinterName: name of the current printer. plugin can then use to access the driver's helper functions Cpatterns: such as Drv WriteSpool Buf. phsurfpatterns: 45 cGdiInfo: pGdiInfo: HRESULT Publish DriverInterface( cDevinfo: IUnknown * pIUnknown pDevinfo: These parameters are identical to what is 50 ); passed into DrvEnablePDEV. pded: points to a function table which contains the System The GetImplemented Method function allows the driver to driver's implementation of DDI entry points. get information about the implemented methods of the pDevOem: OEM PDEV. 55 interface. The OEM plugin must define all of the member Return Value functions of a given interface, but not all of the functions S OK if the function Succeeds, E FAIL if it fails, or need to be implemented. This function is called by UnidrV5 E NOTIMPL if it is not implemented. to determine which of the members of the interface are implemented by the OEM plugin. 60 HRESULT DisablePDEV( HRESULT PDEVOBJ pdevob GetImplemented Method ( ); PSTR pMethodName 65 ); If Enable PDEV is implemented, then during DrvDisablePDEV, the driver will call the OEM DLLs US 6,825,941 B1 31 32 Return Value OEMDriverDMS. This can be changed on a job by job basis. S OK if the function Succeeds, E FAIL if it fails, or The UI has to be customized in order for the OEM to get this E NOTIMPL if it is not implemented. capability. If the OEM does not want it to be modified on a In a preferred embodiment, the Unidriver is a bitmap job by job basis but permanently for all jobs, the OEM does Surface driver. This means that GDI manages the Surface not have to create a custom UI-they just have to always completely. Vector graphics and raster are rendered together return the proper parameters in OEMDriverDMS in the in the same band and sent to the printer. The driver does not render DLL. If the OEM DLL does not return an answer for distinguish between a pie chart and bitmap Sent from a OEMDriverDMS or returns an error, then a Bitmap surface Windows application. High-level printer graphics languages is created by default. like, PCL5 and PCL-XL, have the capability to distinguish The DrvTextOut call is sent to OEM minidriver. OEM between vectors and raster. PCL5c will even color treat the will have to handle text clipping, text rotation, underline, objects differently based on the type of object it is drawing. and strikethrough. The OEM should also sent commands for For the current Unidriver, vectors and raster are color treated text brush. Unidriver provides a helper function, as raster, So the output may not be color corrected in the manner intended by the user. Preferably, the Unidriver 15 DrvUniTextOut, to do the actual textout. This helper call allows the creation of a device managed Surface. GDI cannot expects the same parameters as DrVTextOut. After Sending manage a device Surface Since it has no knowledge of the commands for text brush, rotation and clipping, OEM calls physical device. This means a device-managed driver will be the Unidriver helper function DrvUniTextOut to do the required to draw its own graphics through the OEM mecha actual text. In a preferred embodiment, rotation is not nism. It is not possible for a device-managed driver to call Supported and glyph based clipping is done by Drvuni any Eng calls that perform drawing onto the Surface. TextOut. An alternative embodiment allows the OEM driver However, a device-managed Surface does not render graph to do the clipping. ics into bands and has more control over when objects are OEMs must export a new function that will draw the text Sent to the printer. as bitmap. The function OEMTextOutASBitmap utilizes the The OEM must create a custom-rendering module 25 same parameters as DrvTextOut. DrvUniTextOut may call described in oemcust.doc. In addition to OEMGetInfo and OEMTextOutASBitmap if the text cannot be downloaded. OEMDevmode, the OEM must also export OEMDriver This can happen when downloading fails or text is rotated. DMS. An alternative embodiment gives the OEM the opportunity The OEMDriverDMS function is called during DrvEn to rotate the text. If the OEM does not want to rotate the text, ableSurface to determine the type of Surface to create it can always call the OEMTextOutASBitmap routine to Bitmap or Device. rasterize the text. BOOLAPIENTRY After DrvUniTextOut is complete the OEM will have to draw underline and Sytike throughs. Underline and OEMDriverDMS ( Strikethrough come into the function call as a Series of IN PDEVOBJ pDevObj, 35 rectangles in prelExtra. The OEM driver can creates rect OUT PVOID pBuffer, angles based on the coordinates in prelBXtra using vector IN DWORD cbSize, commands. OUT PDWORD pcbNeeded 40 kDMs driver cannot call GDI provide Eng drawing calls DrvniTextOut code looks like: to render onto the device managed Surface. It can however if(Download Font) create a temporary bitmap Surface and pass that as drawing { surface to Eng calls. All DDI rendering calls must be If send the glyphs hooked. 45 else if font could not be downloaded These are: { if(DEVICE MANAGED()) DrVRealizeBrush pfnOEMTextOutAsBitmap (...); DrvDitherColor else DrvCopyBits EngTextOut(...); 50 DrVBitBlt DrVStretch Blt UnidrV5 supports OEM customization in following areas: DrVStretch BltROP GPD command callback, raster data processing callbacks, DrvPlgBlt and font handling callbacks. The OEM can choose what DrvTransparentBlt 55 callbacks to provide individually based on the Specific needs of the printer. Support for OEM DLL modification of the Drv AlphaElend print Stream will be implemented through command call DrvGradientFill backs as defined in the GPD. For any GPD command, the DrvTextOut OEM can specify a unique callback identifier via Call DrvStrokePath 60 backID entry inside any GPD * Command construct. This identifier, a positive integer, will be passed to the minidriver DrVFPath during callback as one of the parameters (see below). At DrvStrokeAndFillPath print time, when UnidrV5 is ready to emit a command but DrVPaint finds out that it is a callback id instead, it will call the DrvLineTo 65 minidriver's implemented command callback routine with DrvEnableSurface is not hookable. The Unidriver creates the command ID and a parameter list as Specified by the type of surface based on the information derived from * Params entry in the same *Command construct. US 6,825,941 B1 33 34 this ColorMode option. Finally, if DrvBPP specifies higher color depth than * DevBPP/*DevNumOfPlanes, there must be a valid IPCallbackID entry in this ColorMode option, HRESULT and only OEM supported halftone should be available. CommandCallback.( PDEVOBJ pdevobj, It is the responsibility of the GPD author to provide the DWORD dwCmdCbID, correct UI constraints between the ColorMode options and DWORD dwCount, the Halftone options So only desired combinations can be PDWORD pdwParams selected. For GDI halftoning, the GPD can enumerate as INT * piResult halftone options one or more GDI built-in patterns or OEM defined patterns. A built-in GDI halftoning option must be assigned one of the predefined symbol names. For OEM pdevobj: pointer to the DEVOBJ. defined patterns (up to 256x256 in size), the option must dwCmdCbiD: the command callback ID as specified in contain the entry *HTPatternSize and also *rcHTPatternID the GPD file. if the pattern is stored in the resource file. An optional OEM dwCount: the count of the number of parameters (each a 15 callback to perform image processing may be specified in DWORD value) in pdwParams list. the ColorMode. Note that the GPD should not supply an pdwParams: pointer to an array of DWORD parameter invocation string for an OEM defined dither pattern since values in the same order as Specified by the correspond this is not a printer feature. ing Params entry in the GPD file. For halftoning performed by an OEM callback, the Half piResult: 0 for most GPD commands except X/Y move toning option need only specify the name of the option to be ment commands in which case, the return value is the displayed in the halftoning listbox. The control module will difference (positive) between the requested cursor posi pass the index of this option as a parameter into the callback tion VS. the actual cursor position that the command has function ImageProcessing which should take the appropriate imposed. action based on the value of this index. For halftoning performed by the printer, an invocation String is required. An Return Value 25 optional OEM callback to perform image processing may be S OK if the function Succeeds, E FAIL if it fails, or specified in the ColorMode. Again the index of the halftone E NOTIMPL if it's not implemented. option selected will be passed down to the OEM callback (if If a command callback requires no parameter, then any is used). dwCount is set to 0 and pdwParams is NULL. The ImageProcessing callback allows the OEM to access, The ColorMode feature of GPD, as described in detail manipulate and convert the format of the Shadow bitmap below, allows the GPD author to specify the format of the after all GDI imaging is complete and before any dump shadow bitmap (format in which GDI performs imaging processing is performed. It also allows the OEM to perform operations), the format of the bitmap to be dumped to the the dumping of the raster bitmap data directly to the printer. printer and an OEM callback function (ImageProcessing) AS mentioned in the discussion of ColorMode, the OEM which may be used to perform the transformation from GDI 35 may specify the format of both the Shadow bitmap imaged to dump format. The OEM callback may perform halftoning to by GDI and the format of the bitmap to be dumped by the (conversion to a dump format with Smaller pixel depth than driver. As a result, the OEM may cause the halftoning to be the GDI format) or image processing (like color performed by GDI at imaging time, in adjustments, ink removal) or both. Depending on the con OEMImageProcessing, or by the printer. The following is figuration specified, the halftoning may actually be per 40 formed by GDI, by the OEM callback or by the printer itself. the function prototype required for ImageProcessing: See the GPD spec for examples. Multiple ColorMode options may be specified so the user may Select the desired output color depth, halftone proceSS HRESULT etc. Different sets of halftone options are available for each 45 ImageProcessing( PDEVOBJ pdevobi, ColorMode. The OEM callback (if used) may provide, via BYTE pSrcBitmap, the custom UI extensions, additional controls to allow the PBITMAPINFOHEADER pBitmapInfoHeader, user to adjust various properties of the printed image. If So PBYTE pColorTable, desired, the OEM may allow ImageProcessing to perform DWORD dwCallbackID, the dumping of the raster bitmap to the printer by Setting the 50 PIPPARAMS pIPParams, keywords *DevNumOfPlanes and *DevBPP to zero in the PBYTE *ppbResult ColorMode option. The halftone options enumerated in the GPD fall into one of 3 categories: GDI supported, OEM supported, and device pdevobj: pointer to the DEVOBJ. Supported (requires invocation String to enable). A custom 55 pSrcBitmap: pointer to the Source Shadow bitmap. halftone pattern, although defined by the OEM in the GPD, pBitmapInfoHeader: describes source bitmap, DIB is considered a GDI supported halftone because GDI does format, topdown Scan ordering. the actual work. For any given ColorMode option, only one In a preferred embodiment, 1, 4, 8, and 24 BPP formats of the three halftone categories is applicable. First, if are Supported (planes=1) with no compressed formats Sup *DrvBPP is 1 or 4 BPP and specifies the same color depth 60 ported. Both Source and destination formats will be orga as *DevBPP/*DevNumOfPlanes, then only GDI supported nized as DIBs with ulPrimary Order=PRIMARY halftone should be available. For this purpose, 4 bpp ren ORDER CBA. For example, if the format is RGB(CMY), dering depth is considered an exact match for any of 4 bpp, the ordering of the color planes in each pixel is: least RGB, CMY, or CMYK output depth. Second, if *DrvBPP is significant m bits are B(Y), next m bits are G(M), and next 24 BPP and specifies the same color depth as * DevBPP/ 65 m bits are R (C) where m is 8 for 24 BPP and 1 for 4 BPP * DevNumOfPlanes then device Supported halftoning is The black plane (if any), occupies the next m bits. If there assumed whether or not there is a *IPCallbackID entry in are unused bits, these will be the most significant bits. The US 6,825,941 B1 35 36 driver assumes the OEM callback creates plDestBitmap to output bitmap. This callback may also be used to dump the the pixel depth specified in the GPD information so the bitmap directly to the printer without any further assistance callback should not change pBitmapnfo. or intervention from the driver. The driver assumes OEMIm pColorTable: It is the source palette if the format is 8bpp. ageProcessing will perform the dump if *DevNumOfPlanes It gives the OEM access to the source palette which can and Dev BPP are set to 0 in the ColorMode. If the OEM be used to halftone the data to customize the printer's DLL is assuming the responsibility of dumping the raster palette by creating a new 8 bit colortable. If the OEM bitmap, it should use the XMoveTo and YMoveTo unidrV5 wishes to create a new 8 bpp palette the OEM module provided functions to do all the required positioning. If the will be responsible for downloading the data. dl wishes to do its own positioning it will still need to dwCallbackID: the callback ID value specified in the update the current driver cursor position on exit by calling ColorMode option (IPCallback) in the GPD file. This XMoveTo and YMoveTo with the MV UPDATE flag set. Selects one particular image processing method if the If the Compression callback is provided by the OEMDLL ColorMode specifies multiple image processing call and the CmdEnable OEMComp command is defined in the back ids. GPD, the callback will be used to compress the next block pIPParams: Pointer to IPPARAMS structure containing 15 of data. The relative size of the newly compressed data will current driver State information. be compared to any other enabled unidrV5 compression modes to determine the most efficient compression algo rithm for this block of data. If it results in the Smallest size, typedef struct { unidrV5 will send the CmdEnable OEMComp command DWORD dwSize: followed by the data. The OEM function only compresses POINT ptOffset; and returns the data and is not responsible for any output. PSTR pHalftoneOption; UnidrV5 will provide a buffer in which to compress the data. BOOL bBanding: BOOL bBlankBand; The size of this buffer will be specified and may represent IPPARAMS, *PIPPARAMS; the size of best compression algorithm checked So far. In this 25 way an early out algorithm can be used to Stop compressing if it is not going to result in Smaller output. dwSize: size of this structure in bytes. ptOffset: offset of the band relative to upper left corner of imageable area. pHalftone Option: String pointer to the name of the HRESULT Compression ( currently selected halftone option. The callback PDEVOBJ pdevobi?/Pointer to DEVOBJ should know what each option corresponds to in the PBYTE pInBuf, ?/Pointer to raster data to compress GPD file. It uses this to determine what type of PBYTE pCutBuf, ?/Pointer to output buffer for compressed data halftoning to provide. DWORD dwInLen, //size of input data to compress DWORD dwOutLen, //size of output buffer in bytes bBanding: flag Specifying banding is active when 35 INT piResult TRUE. bBlankBand: flag Specifying that nothing was drawn in ); the input bitmap so it should be considered blank when TRUE. Since nothing needed to be drawn in piResult: Contains the number of compressed bytes cre the bitmap it wasn’t erased So the bitmap data is 40 ated if Successful otherwise-1 if unable to compress invalid and should not be used. the data within the specified buffer. ppbResult: caller Supplied address of a pointer to the Return Value destination bitmap buffer if successful and NULL (0) if S OK if the function Succeeds, E FAIL if it fails, or unsuccessful when the OEM function is not dumping E NOTIMPL if it's not implemented. the data itself. If the function will dump the data then 45 The Compression callback can be used to implement a it should return TRUE if successful or FALSE (0) if Special compression method that may or may not be more not. The destination bitmap may be in the same format efficient than existing unidrV5 compression modes thus as the Source bitmap. It may point to the same memory allowing the best method to be utilized. Since there is some as pSrcBitmap or point to a buffer allocated by the overhead involved with compressing the data the OEM OEM. Currently, 1, 4, 8 and 24 BPP (planes=1), are 50 should only enable those compression methods most likely valid formats that can be returned in the destination to yield the best results. To utilize this callback the device bitmap where ulPrimaryOrder must be PRIMARY must be able to Switch compression modes and Support ORDER CBA with topdown scan ordering. The bit disabled compression on a per Scan line basis. map data is then dumped to the device as Specified in If FilterGraphics callback is provided by the OEM DLL, the GPD file with the exception that in 4 BPP, no black 55 it will be used in place of the driver's normal blockout/ synthesis or RGB to CMY conversion will take place so compression code for Sending a block of raster data to the the OEM callback is responsible for initializing all 4 printer. The number of Scanlines in a block is specified by planes. This will allow the OEM the option of imple * PinsPerPhysPass entry of the current Resolution option. menting a more Sophisticated black Synthesis. For most inkjet printers and page printers, this number is 1. Return Value 60 S OK if the function Succeeds, E FAIL if it fails, or E NOTIMPL if it's not implemented. HRESULT FilterGraphics( This callback will be made immediately before the driver PDBVOBJ pdevobi, executes its own code to render the bitmap. The callback is PBYTE pBuf, // Pointer to buffer containing scanline raster expected to allocate any buffers it requires to perform the 65 data to be bitmap conversion or image processing. The callback may If compressed/manipulated and sent out. overwrite the Source bitmap, or it may allocate its own US 6,825,941 B1 38 -continued GPD. When one, the same pattern is used for all color planes. Otherwise three different patterns are defined DWORD dwLen if length (in bytes) of the buffer ); which allows a different halftone pattern for each color. dwCallbackID: the callback ID value specified in the Halftone option (HTCallback) in the GPD file. This Return Value selects one particular halftone method if the Halftone S OK if the function Succeeds, E FAIL if it fails, or option specifies multiple halftoning callback ids. E NOTIMPL if it's not implemented. The FilterGraphics callback can be used to implement a pResource: Pointer to the resource found for this halftone Special compression method, or to perform bit manipulation type. If NULL it implies the function will generate a on the data Stream that is sent to the printer, or both. In either halftone pattern internally. case, the driver's built-in compression code is not used. dwResourceSize: Size of the resource if any. If pResource FilterGraphics is presented with a block of data and it is is NULL this will be Zero. required to send all the data and using Drv WriteSpool Buf. Return Value The driver will perform no further processing of the raster data after calling FilterGraphics. This callback is expected to 15 S OK if the function Succeeds, E FAIL if it fails, or allocate any buffers it requires, Such as to perform the E NOTIMPL if it's not implemented. compression. The callback may overwrite the source buffer If the Memory Usage callback is provided by the OEM if the compressed results occupy fewer bytes than the DLL, it will be used to determine the amount of memory original data. Otherwise it must allocate its own output required by the ImageProcessing function. This information buffer. Any memory allocated by FilterGraphics may be will be used to adjust the optimum size of the shadow bitmap freed at DisablePDEV time. for banding. For example, if GDI reports that the optimum Since Some compression methods under certain situations memory to use for banding is 8MB this value will be may produce more data than the original, it is recommended reduced by the results of this function and a smaller band the OEM callback not to overwrite the input data buffer. If will result. If this function does not exist it will be assumed the compressed results are worse, it may wish to disable 25 that the memory usage is negligible. compression for this block and emit the original data uncom pressed. The OEM is responsible for inserting any compres Sion invocation command in front of the compressed data if HRESULT needed MemoryUsage ( If HalftonePattern callback is provided by the OEM DLL PDEVOBJ pdevobi, and the GPD provided HTCallbackID parameter is greater POEMMEMORYUSAGE pMemoryUsage than 0, the callback will be used to generate a custom OEM halftone pattern for GDI halftoning when the OEM wishes to keep the pattern proprietary. This is accomplished by 35 pdevobj: pointer to the DEVOBJ. either encrypting it in the resource dll or generating it in the pMemory Usage: Pointer to structure to be filled in by OEM dll. If the rcHTPatternID is Zero it is assumed there is OEM function specifying memory requirements. no resource and that this callback will generate a pattern on the fly. If a valid ID does exist, unidrV5 will retrieve the resource and if this callback exists, let it unencrypt or otherwise modify the pattern. If this callback does not exist 40 typedef struct { and halftone resource is valid it is assumed the resource is DWORD dwFixed MemoryUsage; // fixed memory used by function in bytes not encrypted and will be used directly. DWORD dwPercentMemoryUsage; // variable memory used as a percentage of shadow bitmap DWORD dwMaxBandSize: If in 45 parameter, specified current max band size HRESULT OEMMEMORYUSAGE, POEMMEMORYUSAGE: HalftonePattern ( PDEVOBJ pdevobi, PBYTE pHTPattern, Return Value DWORD dwHTPatternX, DWORD dwHTPatternY, 50 S OK if the function Succeeds, E FAIL if it fails, or DWORD dwHTNumPatterns, E NOTIMPL if it's not implemented. DWORD dwCallbackID, The fixed memory usage specifies the amount of memory PBYTE pResource, used independent of the size of the shadow bitmap. The DWORD dwResourceSize variable memory usage is Specified as a percentage of the 55 memory used by the shadow bitmap. For example if the shadow bitmap is 24 BPP and the OEMImageProcessing pdevobj: pointer to the DEVOBJ. function is going to halftone it down to 4 BPP into a separate pHTPattern: Pointer to location to store halftone pattern buffer then the dwpercentMemoryUsage should be set to with a size of (((dwHTPatternX*dwHTPatternY)+3)/ about 17 since the buffer will be about 17% of the size of the 4)*4*dwHTNumPatterns bytes. Each individual pat 60 shadow bitmap. The dwMaxBandSize parameter is an in tern must be DWORD aligned. parameter that Specifies what the maximum band size will be dwHTPatternX: The X size of the custom halftone pattern if both Memory Usage parameters are Set to Zero. as specified in the GPD. UNIDRV5 font module callback interface is a GDI dwHTPatternY: The Y size of the custom halftone pattern object-like interface. Callback functions have UNIFON as specified in the GPD. 65 TOBJ as a parameter, which is a font module callback dwHTNumPatterns: The number of dither patterns interface base object. Basic information is Stored in this defined which will be either 1 or 3 as specified in the object. Additionally UNIDRV5 provides a service function US 6,825,941 B1 39 40 for minidrivers to let them get an extra information. Minid Return Value river must not change UNIFONTOBJ members. S OK if the function Succeeds, E FAIL if it fails, or E NOTIMPL if it's not implemented. The Output.CharStr callback is provided for a character 5 code manipulation. Minidriver can convert a character code typedef BOOL (PFNGETINFO)(PUNIFONTOBJ, DWORD, PVOID); to an appropriate one for the printer. If minidriver needs to typedef struct UNIFONTOBJ { ULONG uIFontLD; if download id . . . get the width data of a character, minidriver can get the If Font Resource id incase of Device Fonts. width by UNIFONTOBJ GetInfo callback or access UFM DWORD dwFlags; // General Flags. data directly to get width table. IFIMETRICS pIFIMetrics: If Pointer to IFIMETRICS. PFNGETINFO pfnGetInfo: If Pointer to UNIFONTOBJ GetInfo 1O callback. } UNIFONTOBJ, *PUNIFONTOBJ; HRESULT If || UNIFONTOBJ.dwFlags OutputCharStr( If PDEVOBJ pdevobi, 15 PUNIFONTOBJ puFObi, #define UFOFLAG TTFONT OxOOOOOOO1 DWORD dwType, // only set if this is TrueType font. DWORD dwCount, #define UFOFLAG TTDOWNLOAD BITMAP OxOOOOOOO2 PVOID pGlyph): #define UFOFLAG TTDOWNLOAD TTOUTLINE OxOOOOOOO4 #define TYPE UNICODE 1. #define TYPE TRANSDATA 2 #define TYPE GLYPHHANDLE 3 UNIFONTOBJ.dwFlags is set by UNIDRV5. A minidriver #define TYPE GLYPHID 4 must not change this flag. Pdevobi Pointer to the DEVOBJ PUFObi Pointer to the UNIFONTOBJ This function downloads the font header as an appropriate DwType Type of pglyph string. One of following is format to a printer to create download font. UNIDRV5 specified by UNIDRV5. TYPE GLYPHHANDLE supports only PCL type bitmap/TT outline download. If a 25 TYPE GLYPHID printer has bitmap/outline font download feature of which DwCount Number of the glyph store in pClyph format is different from PCL format, minidriver can support PGlyph Pointer to glyph string to HGLYPH* (TYPE GLYPHHANDLE) its download format by providing the font download call Glyph handle that GDI passes. backs. If minidriver Supports this function, it has to Support DWORD (TYPE GLYPHID). Glyph ID DownloadCharGlyph callback function as well. that UNIDRV5 creates from Glyph Handle. In case of TrueType font, string type is HGLYPH*. For Device font, string type is DWORD*. HRESULT Download FontHeader( PDEVOBJ pdevobi, 35 Return Value PUNIFONTOBJ puFObi, S OK if the function Succeeds, E FAIL if it fails, or DWORD *pdwResult); E NOTIMPL if it's not implemented. Pdevobi Pointer to the DEVOBJ PUFObi Pointer to the UNIFONTOBJ Before downloading a TrueType font, UNIDRV5 calls PdwResult Contains the amount of necessary mem this function to determine which format is supported or if ory to download the font header 40 TrueType can be downloaded for this font given the current Situation. Return Value

S OK if the function Succeeds, E FAIL if it fails, or HRESULT E NOTIMPL if it's not implemented. 45 TTDownloadMethod( The DownloadCharGlyph function download the charac PDEVOBJ pdevobi, PUNIFONTOBJ pFontObj, ter glyph data. There are two glyph data formats that are DWORD *pdwResult); Supported: bitmap and TrueType outline. #define TTDOWNLOAD DONTCARE O #define TTDOWNLOAD GRAPHICS 1. 50 #define TTDOWNLOAD BITMAP 2 #define TTDOWNLOAD TTOUTLINE 3 HRESULT Pdevobi Pointer to the DEVOBJ. DownloadCharGlyph.( PfontObi Pointer to the FONTOBJ. PDEVOBJ pdevobi, PUNIFONTOBI pUFObj, HGLYPR hClyph, 55 pdwResult: PDWORD pdwWidth, TTDOWNLOAD DONTCARE Minidriver does not DWORD *pdwResult); care how this font is handled. Pdevobi Pointer to the DEVOBJ. PUFObi Pointer to the UNIFONTOBJ TTDOWNLOAD GRAPHICS Minidriver prefers HGlyph Glyph handle to downlooad. printing this TT font as graphics. PdwWidth Pointer to the DWORD width buffer. 60 TTDOWNLOAD BITMAP Minidriver prefers down Minidirer has to set the width of downloaded glyph data. load this TT font as bitmap soft font. PdwResult Necessary amount of memory to TTDOWNLOAD TTOUTLINE Minidriver prefers download this character glyph in the downloading this TT fonta as TT outline soft font. printer. If returning O, UNIDRV5 This printer must have TT rasterizer support. assumes that this function failed 65 UNIDRV5 will provide pointer to the memory mapped TT file, through callback. The minidriver has to parser the TT file by itself. US 6,825,941 B1 41 42 Return Value S OK if the function Succeeds, E FAIL if it fails, or -continued E NOTIMPL if it's not implemented. UNIDRV5 supports only PCL Scalable font select com DwnfoD Functionality mand format. If OEM printer supports a different command 5 UFO GETINFO MEMORY Get remained memory format from PCL for Scalable font select command, minid UFO GETINFO STDVARIABLE Get GPD standard variable. river has to Support this callback function. The Select com mand in font metricS data is passed in FInv parameter and the minidriver can customize the command String before Minidriver has to pass a pointer to GETINFO sending it via Drv WriteSpool Buf. FONTOBJ structure in pData and dwSize in GETINFO FONTOBJ structure. UNIDRV5 sets a pointer to FONTOBJ in GETINFO FONTOBJ.pFontObj. This function is avail able in any font callback function. HRESULT SendFontCmd( PDEVOBJ pdevobi, 15 PUNIFONTOBJ puFObj, typedef struct GETINFO FONTOBJ { PFINVOCATION pFInv); DWORD dwSize: || Size of the buffer. typedef struct FINVOCATION { FONTOBJ pFontobi: || Pointer to FONTOBJ DWORD dwCount: If Size of command } GETINFO FONTOBJ, PGETINFO FONTOBJ; PBYTE pubCommand; If Pointer to font selection command } FINVOCATION, PFINVOCATION: Minidriver has to pass a pointer to GETINFO GLYPHSTRING structure in p[Data. A minidrver sets values Pdevobi Pointer to the PDEVOBJ. in dwSize, dwType In, dwTypeOut and pClyph In, and pre PUFObi Pointer to the UNIFONTOBJ pares a buffer for pGlyphOut. UNIDRV5 returns glyph data PFInv Pointer to the FINVOCATION 25 in pGlyphOut. This function is available for printer device Return Value fonts in any font callback function. But for TrueType font, S OK if the function Succeeds, E FAIL if it fails, or only characters that is passed via DrvTextOut can be handled E NOTIMPL if it is not implemented. by UNIDRV5. Example: UFM has the font selection command in it. Following is the example of font Selection command. typedef struct GETINFO GLYPHSTRING { DWORD dwSize: if Size of the buffer. DWORD dwTypeIn: If Type of glyph.TYPE GLYPHID or UNIDRV5 passes this selection command in pRInv. TYPE GLYPHHANDLE pFInv->dwCount=57; 35 PVOID pGlyph In; // Glyph string DWORD dwTypeOut:// Type of glyph.TYPE UNICODE pFInv->pubCommand= or TYPE TRANSDATA “\x1B(9U\x1B(s4148t0b0s#FontHeight 1PW1B)6J\x1B) PVOID pGlyphOut:/f Glyph string to be filled by UNIDRV5 S4148tObOSiRont Width 1P } GETINFO GLYPHSTRING, PGETINFO GLYPHSTRING: In this callback function, a minidriver has to Set correct 40 value in #FontHeight and #FontWidth, using UNIFONTOBJ Minidriver has to pass a pointer to GETINFO information. And it sends to the printer. GLYPHDATA structure in plData and set dwSize. Minidriver UNIFONTOBJ provides GDI-object-like callback inter sets values in dwGlyphID and dwType. UNIDRV5 returns face for minidrivers. Minidriver can query a necessary glyph data in pGlyph Data. This function is available in any information with this interface. 45 font callback function.

BOOL typedef struct GETINFO GLYHPHDATA { UNIFONTOBJ GetInfo( DWORD dwSize: If Size of the buffer. UNIFONTOBJ puFObi, 50 HGLYPH hGlyph; // Glyph handle DWORD dwInfoID, PVOID pData); GLYPHDATA pGlyph Data; II Pointer to GLYPHDATA PUFObi Pointer to the UNIFONTOBJ } GETINFO GLYPHDATA, PGETINFO GLYPHDATA: DwnfoD Type of information to get PData Pointer to the data structure Minidriver has to pass a pointer to GETINFO 55 GLYPHWIDTH structure in pData. In GETINFO Return value: Return TRUE if Succeeds. Otherwise, FALSE. GLYPHWIDTH structure minidriver has to set the type of This function Supports following functionality to return glyph, UNICODE or Glyph Handle. And set a pointer to the data to the minidriver. Strings.

60

DwnfoD Functionality typedef struct GETINFO GLYHPHWIDTH { DWORD dwSize: If Size of the buffer. UFO GETINFO FONTOBJ Get FONTOBJ DWORD dwType: || TYPE GLYPHHANDLE or UFO GETINFO GLYPHSTRING Get glyph string TYPE GLYPHID. UFO GETINFO GLYPHDATA Get glyph data 65 DWORD dwCount; // Count of glyph. UFO GETINFO GLYPHWIDTH Get glyph width data PVOID pvOlyph; // Glyph string of which width data is required. US 6,825,941 B1 43 44

-continued -continued PLONG plWidth: || Width buffer to be filled by UNIDRV5. DWORD cbSize, } GETINFO GLYPHWIDTH, PGETINFO GLYPHWIDTH: PDWORD pcbNeeded ); Minidriver has to set the type of glyph and glyph width data. pDevObj: Driver's PDEV. Minidriver has to pass a pointer to GETINFO pBuffer: Pointer to output buffer which holds the return data. pBuffer is used to find out if the driver will be a MEMORY structure in plData. bitmap Surface driver or a device managed driver. If OEMGetInfo returns FALSE, the default mode will be a bitmap surface driver. If pBuffer is 0 a bitmap surface typedef struct GETINFO MEMORY { is created in DrvEnableSurface. If pBuffer is not 0, then DWORD dwSize: If Size of the buffer. 15 a device managed Surface is created. The pBuffer value DWORD dwRemainingMemory; // UNIDRV5 returns the remaining memory. is used as flooks in the EngASSociateSurface call. } GETINFO MEMORY, PGETINFOR MEMORY: cbSize: Specifies the size of the buffer pointed by p3uffer. pcbNeeded: Pointer to a DWORD. Returns the number of bytes written into the output buffer by the OEM plugin. If Minidriver has to pass a pointer to GETINFO the output buffer is not large enough, OEM plugin should FONTOBJ structure in pdata. Minidriver can get standard return FALSE and set the error code to ERROR variables from UNIDRV5 at any time in font callback. INSUFFICIENT BUFFER. In that case, this variable returns the size of the expected output buffer. Return Value typedef struct GETNFO STDVAR { 25 S OK if the function Succeeds, E FAIL if it fails, or DWORD dwSize: If Size of the buffer. E NOTIMPL if it is not implemented. The reason for DWORD dwNumOf Variable; the failure should be set via SetLastError. struct { For DMS Support, OEMs must export this function that DWORD dwStdVarID; LONG |StdVariable: will draw the text as bitmap. The function TextOutASBitmap Stdvar 1: will have the same parameters as DrvTextOut. } GETINFO STDVER, *PGETINFO STDVER:

TextOutAsBitmap( #define FNT INFO PRINT DIRINCCDEGREES SURFOB *pso, O/PrintDirInCCDegrees 35 STROBJ *pstro, # define FNT INFO GRAY PER CENTAGE FONTOBJ *pfo, CLIPOBJ *pco, 1//GrayPercentage RECTL prelExtra, ifdefine FNT INFO NEXTFONTID 2//NeXtfont) RECTL *prelOpaque, BRUSHOB *pboFore, #define FNT INFO NEXTGLYPH 3//NextGlyph 40 BRUSHOB *pboCopaque, #define FNT INFO FONTHEIGHT 4/FontHeight POINTL *pptlOrg, #define FNT INFO FONTWIDTH 5/FontWidth MDX mix # define FNT INFO FONTINT LEADING 6//FontntLeading 45 Return Value ifdefine FNT INFO FONTBOLD 7//FontBold S OK if the function Succeeds, E FAIL if it fails, or ifdefine FNT INFO FONTITALIC 8//Fonttalic E NOTIMPL if it is not implemented. The reason for the # define FNT INFO F O N TUNDERLINE failure should be set via SetLastError. 9//Fontlunderline The following call back is required for Text Only minid #define FNT INFO FONTSTRIKETHRU 10// 50 river. The TTYGetInfo callback need not be implemented by FontStrikeThru other OEMs minidrivers. This callback function is used to ifdefine FNT INFO CURRENTFONTID 1 1//Current get the information, like margin, from Text Only minidriver. ifdefine FNT INFO TEXTYRES 12//Texty Res ifdefine FNT INFO TEXTXRES 13//TextXRes 55 HRESULT #define FNT INFO MAX 14 TTYGetInfo( The following callbacks are used for Device Managed PDEVOBJ pdevobi, Surface. The DriverDMS function is called during DrvEn DWORD dwinfondex, PVOID pOutputBuf, ableSurface to determine the type of Surface to create DWORD dwSize, Bitmap or Device. 60 DWORD *pcbcNeeded);

pDevObj: Driver's PDEV. HRESULT dwinfondex: Information Index for which call is made. DriverDMS( PVOID pDevObj, 65 Currently following indexes are Supported PVOID pBuffer, ifdefine OEMTTY INFO MARGINS 1 #define OEMTTY INFO CODEPAGE 2 US 6,825,941 B1 45 46 pOutputBuffer: Buffer where data will be copied. MV GRAPHICS: the given x (y) value is in the dwSize: Specifies the size of the buffer pointed by pCut graphics resolution unit (as defined by DPI entry of putBuffer. the currently selected resolution). If this flag is not pcbNeeded: Pointer to a DWORD. Returns the number of Set, then the given X (y) value is in the master unit. bytes written into the output buffer by the OEM plugin. 5 MV PHYSICAL: the given x (y) value is relative to If the output buffer is not large enough, OEM plugin the printer's cursor origin. If this flag is not Set, then should return FALSE and set the error code to the given X (y) value is relative to the printable ERROR INSUFFICIENT BUFFER. In that case, origin. Note that this flag cannot be set if this variable returns the size of the expected output MV RELATIVE is set. buffer. 1O Return Value piResult: Contains the difference (in the master unit) S OK if the function Succeeds, E FAIL if it fails, or between the requested move amount and the actual E NOTIMPL if it is not implemented. The reason for move amount. It is always positive. the failure should be set via SetLastError. The DrvoietStandard Variable function is used by OEM to The printer driver of the instant invention provides a retrieve state variables known to Unidriver. helper function interface to the OEM DLL. These helper 15 functions are obtained by the OEM DLL through querying the driver for its helper function interface. HRESULT DrvCietStandard Variable( PDEVOBJ pdevobj, HRESULT DWORD dwindex, DrvWriteSpoolBuf( PVOID pBuffer, PDEVOBJ pdevobi, DWORD cbSize, PVOID pBuffer, PDWORD pcbNeeded DWORD cbSize, ); DWORD *pdwResult 25 pdevobj: points to DEVOBJ structure. pdevobj: points to DEVOBJ structure dwindex: index of standard variable to retrieve. pBuffer: points to the buffer of data to be sent to the pBuffer: Pointer to output buffer which holds the return Spooler. data. cbSize: number of bytes in the buffer. cbSize: Specifies the size of the buffer pointed by pBuffer. pdwResult: contains the number of bytes actually sent to the Spooler. pcbNeeded: Pointer to a DWORD. Returns the number of Return Value bytes written into the output buffer by the Unidriver. If S OK if the function Succeeds, E FAIL if it fails, or 35 the output buffer is not large enough, Unidriver will E NOTIMPL if it is not implemented. return E FAIL and set the error code to ERROR INSUFFICIENT BUFFER. In that case, this variable returns the size of the expected output buffer. OEM should allocate a buffer of this new size and call this HRESULT 40 function again. DrvXMoveTo( PDEVOBJ pdevobi, Return Value INT X, DWORD dwFlags, S OK if the function Succeeds, E FAIL if it fails, or INT *piResult E NOTIMPL if it is not implemented. ); 45 HRESULT The reason for the failure should be set via SetLastError. DrvYMoveTo( DrvUniTextOut is provided as a helper call so that OEMs PDEVOBJ pdevobi, do not have to replicate the entire text functionality of INT y, DWORD dwFlags, Unidrive. This helper function expects the same parameters INT *piResult as DrvTextOut. 50

pdevobj: points to DEVOBJ structure. HRESULT X (y): the move value. DrvUniTextOut.( SURFOB *pso, dwFlags: a combination of one or more of the following 55 STROBJ *pstro, flags. FONTOBJ *pfo, MV UPDATE: update the driver's tracking of the cursor CLIPOBJ *pCO, RECTL prelExtra, position but do not Send any printer escapes to position RECTL *prelOpaque, the cursor. If this flag is not set, the driver will send BRUSHOB *pboFore, printer escapes to move the cursor and update its 60 BRUSHOB *pboCopaque, internal cursor tracking. This flag is used when the POINTL *pptlBrushCrg, cursor position is changed due to Sending graphics data MDX mix Or teXt. ); MV RELATIVE: the given X (y) value is relative to the previous cursor position. If this flag is not Set, 65 DrvGetGPDData is provided as a helper call so that then the given X (y) value is the absolute cursor OEMs mini drivers can access vendor Specific binary data position. defined in GPD file. US 6,825,941 B1 47 48 that other embodiments and particulars of a file Structure are possible in accordance with the teachings of the instant HRESULT invention. Therefore, this exemplary embodiment should be DrvgetGPDData( taken as illustrative only, and should not be used to limit the PDEVOBJ pdevobj, Scope of the invention as defined by the appended claims. DWORD dwType, A GPD file composed in accordance with the instant PVOID pInputData, PVOID pBuffer, invention is basically a Series of attribute definitions in the DWORD cbSize, form of ::

-continued -continued Entry Name Description Comments Entry Name Description Comments .HLP). will be used to extend use PPM for page and/or overwrite the de printers). fault help text. *PrintRateppM An integer, printing Optional. If missing *InstalledOp Quoted string. When Optional. If it is missing speed in Pages Per assume 0. tionName there is any installable and there is installable Minute. feature or option speci feature or option speci *FontCartSlots Integer, the number of Optional. If missing, fied in the GPD file via fied via Installable? 1O font cartridge slots on assume 0. “Installable? entry entry, then *rcIn the printer. (defined later), the stalledOptionNameID is parser will synthesize a required. feature for each one. Relocatable Global entries are used to describe attributes Such kind of features or values that may be dependent on printer configuration. always have two options 15 which correspond to They may be placed at the root level to signify this value/ whether the feature? attribute has no Such dependency but may also appear within option is installed or * Option or * case constructs if there is some dependency. For not. This entry will be example the Set of available device fonts may depend on used as the display name whether the printer is in portrait or landscape orientation. for the option which corresponds to Therefore the keyword describing the list of available device “installed state. Note fonts is defined by this spec to be a Relocatable Global that this display name keyword. The specifics of using Relocatable Global key will be used by all such words to express Such dependencies will be introduced later. synthesized features. To Summarize, the classification of keywords into Relocat *rcInstalledOption Integer, the Windows Optional. If it is missing able and non-Relocatable entries is predetermined by the NameID string resource id corres and there is installable 25 ponding to the string feature or option speci parser. It is not user definable. However the user may choose represented by fied via Installable? to treat Relocatable Globals the same as non-Relocatables if *InstalledOptionName. entry, then the attribute represented by that keyword is in fact indepen *InstalledOptionName dent of printer configuration. The following keywords are is required. Relocatable Globals: *NotInstalledOp Quoted string. When Optional. If it is missing tionName here is any installable and there is installable eature or option speci feature or option speci fied in the GPD file via fied via Installable? *Installable? entry entry, then *rcNotIn Entry Name Description Comments (defined later), the parser stalledOptionNameID is will synthesize a feature required. 35 *OEMCustom Data Quoted string, the con Optional. Required if or each one. Such kind tents of the string will OEM calls of features always be presented to an OEM DrvgetGPDData(). have two options plug in module that calls This entry may occur which correspond DrvgetGPDData(). The within a switchfease con o whether the feature? parser and driver does struct. The contents of option is installed or nothing more with this the quoted string may not. This entry will be 40 data. include binary data, ascii used as the display name or both. The contents is or the option which entirely determined by corresponds to "not the GPD writer. installed state. Note hat this display name will be used by all such 45 Grouping constructs are used to define logical entities. synthesized features. The function of a Construct is similar the function of a *rcNotn Integer, the Windows Optional. If it is missing Structure in the C language. A construct allows a more stalledOp string resource id corres and there is installable tionNameID ponding to the string feature or option speci detailed description of a printing attribute than is possible represented by fied via Installable? with a Single Keyword: Value pair. A construct begins with *NotInstalledOp entry, then *NotIn 50 a construct keyword and it is associated value. Examples of tionName. stalledOptionName is required. construct keywords are *Feature, *Option, and * Command. * MaxCopies Integer, the maximum Optional. If missing, The value is a Symbolname that is used to uniquely identify number of copies that assume no support for this instance of the construct. For example the * Command: the printer supports. multiple-copy printing. CmdStartPage construct is distinct from the * Command: *PrintRate an integer, describing the This entry is optional. 55 CmdSleepTimeOut construct. If a construct with the same printer's printing speed If missing, assume 0. in monochrome mode. * Keyword and Symbolname occurs more than once in the The unit for the value is same GPD, the parser understands this to be a redefinition or defined in elaboration of the original instance. Some constructs allow *PrintRateUnit. user-defined instances (symbolnames). For example the user *PrintRateUnit a constant: PPM (pages This entry is required if per minute), CPS (char PrintRate is defined. 60 is free to define as many Feature constructs as he desires, acters per second), labeling each instance using a symbolname of his choosing LPM (lines per minute), in addition to using any of the predefined Feature Symbol IPM (inches per minute for plotters). The GPD names. Some *Options are also user-definable in this file should specify the manner, while Some only allow the use the predefined appropriate unit based 65 Symbolnames. For example user-defined Papersizes are on the printer type (ex. allowed, but the only options allowed for the PageProtect and Collate features are “ON” and “OFF. The construct US 6,825,941 B1 SS S6 keyword and symbol name are followed by one or more The exception to this rule is the InputBin feature, which is entries Surrounded by curly braces. For ease of readability, always the first feature. Options are ordered based on their it is customary to indent all the entries bracketed by the curly appearance in either a case or *Option keyword. The braces. These entries form the body of the construct. An exception to this rule is the Synthesized "Automatically exemplary Set of keywords and Sub-constructs which are allowed within the body of each tpe of construct are Select' InputBin slot which has the meaning that the Form described below. Some keywords are mandatory while oth ToTray assignment table will be used to assign the input Slot ers may be optional. The inclusion of other keywords will based on the Selected paper size. result in a parsing error. If the GPD writer wishes to define the order of the features Two of the most common constructs in this exemplary and options relative to each other, he may declare them embodiment are *Feature and * Option. The *Feature con ahead of any use in the GPD file using empty *Feature/ struct defines a printer feature and provides UnidrV5’s UI * Option constructs, for example: component the necessary information to present to the end-user a control that allows the end-user to Select one or more options for that feature. Various features offer the user 15 *Feature: EconoMode{ *Option: Off{}*Option: On{}} the opportunity to Select a papersize, an input paperbin, to *Feature: Orientation{ *Option: PORTRAIT{}*Option: turn collation, Stapling on/off etc. Each *Feature construct LANDSCAPE CC90{}} contains one or more *Option constructs that at a minimum *Feature: PaperSize: *Option: LETTER{}*Option: enumerates the optionname the UI Should display and the LEGAL{}*Option: EXECUTIVE{} command that should be sent to the printer to invoke or *Option: A4{}*Option: ENV10{}*Option: ENV DL{} Select this particular option. Some features require addi *Option: ENV MONARCHI}} tional information to be supplied to the driver to describe each of the options, for example the driver needs to know the There are two types of UI features: custom features and imageable area of each Supported papersize in order for the Standard features. Custom features are used to describe app to compose its pages properly and to avoid clipping or Special printer features that UnidrV5 can fully implement truncation of the output. All optional and required keywords 25 knowing only the name of the *Feature and *Option for allowed for each construct are enumerated herein. AS an display in the UI and the Selection command (and its order example, the following is a fragment of the Feature con dependency) for invoking the feature. This allows new Struct describing the paper sizes Supported by Canon BJC printer features to be Supported without any modification to 600 printer showing the *Option constructs nested within UnidrV5. For example, on the HP LaserJet 4L, there are the body of the *Feature construct. Note some required Several custom features Such as EconoMode: keyword entries have been omitted for the sake of simplicity.

*Feature: EconoMode *Feature: PaperSize 35 { *Name: “EconoMode' { *DefaultOption: Letter *% the default paper size is Letter. *DefaultOption: Off *Option: Letter *% define Letter option. *Option: Off { { *Name: “Letter 8/2 x 11 inch *Name: “Off 40 *Command: CmdSelect loin. A4 *% define A4 option. { *Order: DOC SETUP.5 *% define the sequencing order { Name: “A4 210 x 297 mm for this command. *Cmd: “GPJL SET ECONOMODE=OFF-0As le define more paper sizes . . . 45 *Option: On { *Name: “On Although it may appear arbitrary, Option constructs *Command: CmdSelect must be nested within Feature constructs. Feature con { *Order: DOC SETUP.5 *% define the sequencing order Structs must always appear at the root level. Every Feature 50 for this command. construct should contain at least one *Option construct. If *Cmd: “GPJL SET ECONOMODE=ON<0As the * Default Option entry is missing, the first option listed is used as the default. If desired, the Default Option may be Specified within Switch/case constructs to express its dependence on the current option Selection of other features, 55 though if this is done, care must be taken when specifying Standard features are used to describe common printer the * ConflictPriority so an inconsistency or circular depen features which UnidrV5 Supports using Special case code. dency does not arise. For example UnidrV5 needs to be aware of the printer's The order of features and options within a feature relative current Landscape orientation Setting Since it will have to to one another has Some effect on the driver. For example, 60 perform the landscape rotation if the printer does not have the UI code displays features and options in the order in rotation capabilities built in. Standard features can have which they appear in the GPD file. This is not a hard and fast additional feature-specific entries that Unidrvis understands rule, and one should consult Specific UI documentation for and uses in printing. For example, PaperSize is a Standard specifics. Also in the absence of a Default Option keyword, feature and its options contain the *PrintableArea entry the first option becomes the default. The current implemen 65 which UnidrV5 uses to determine where pixels and text can tation of the parser considers Features to be ordered based on be placed. The following is an exemplary list of Standard their appearance in either a switch or *Feature keyword. features and options provided for by the instant invention. US 6,825,941 B1 57 58

Standard Features Description Standard Options Comments Orientation The list of logical PORTRAIT, Optional. If missing, the orientations. LANDSCAPE CC90, printer supports only LANDSCAPE CC270. No Portrait logical orientation. custom options. Standard orientation options use the id's defined in Windows SDKIDDK. PaperSize The list of paper sizes CUSTOMSIZE, LETTER, Required. At least one supported on the printer. LETTERSMALL option must be enumerated. These paper sizes will be TABLOID, LEDGER, Standard paper size options enumerated to the apps and LEGAL STATEMENT, use the dimensions and id's used in formatting EXECUTIVE, A3, A4, etc. as defined in Windows documents. All Windows pre-defined SDK/DDK. Custom option paper sizes have associated names cannot exceed the standard names. Custom string length limit options are allowed. CCHFORMNAME defined in wingdi.h in the Windows SDKIDDK. Resolution The list of printing All options are considered Required. At least one resolutions. custom. option must be enumerated. MediaType The list of media types STANDARD, Optional. If missing, the supported. TRANSPARENCY, printer's default media type GLOSSY. Custom options is always used. Standard are allowed. media options use the id's defined in Windows SDKIDDK. InputBin The list of input bins UPPER, LOWER, Required. Standard input supported. MIDDLE, MANUAL, bin options use the id's ENVFEED, defined in Windows ENVMANUAL, AUTO, SDKIDDK. TRACTOR, SMALLFMT, LARGEFMT, LARGECAPACITY, CASSETTE. Custom options are allowed. OutputBin Enumeration of output bins All options are considered Optional. If missing, supported. custom. assume the printer does not support multiple or user selectable output bins. Duplex Two-sided printing. NONE, VERTICAL, Optional. If missing, HORIZONTAL. No assume the printer does not custom options. support two-sided printing. Standard duplex options use the id's defined in Windows SDKIDDK. Collate Collate printed pages or ON, OFF. No custom Optional. If missing, not. options. assume the printer does not support collation. Memory The list of printer memory All options are considered Optional. If missing, configurations. custom. Unidrv5 will not attempt to track memory usage. *FeatureType = PRINTER PROPERTY by default ColorMode The list of color printing All options are considered Optional. If missing, it modes. custom. implies that the printer is monochrome and the driver will render images in 1 bppf1 plane format. Halftone The list of halftoning Custom options are Optional. If missing, only options allowed. the standard halftone methods will be displayed for the user to choose. The default Stapling List of stapling options All options are custom. Optional. However using this feature keyword will cause Directory Services to assume your printer supports stapling. PageProtect The list of page protection ON, OFF. No custom Optional. This feature is options (used on page options. enabled only if the current printers to prevent print printer memory is greater. Overrun errors). than the page protection memory needed for the current paper size. “FeatureType = PRINTER PROPERTY by default US 6,825,941 B1 59 60 If any *Feature or *Option construct is multiply defined, the contents (body) of the separate construct definitions are -continued merged (Union) into a single construct. If this single con *PrintableArea: PAIR(9600, 12648) *% define more Struct now contains 2 or more Statements containing the *% attributes not present in the original construct. Same keyword, the latter occurrence overwrites all previous *Option: A4 *% define A4 option for the first time. occurrences. AS an example: { Name: “A4 210 x 297 mm *% define more paper sizes . . . *Feature: PaperSize 1O { *rcNameID: 2101 * DefaultOption: Letter *% the default paper size is Letter. *Option: Letter *% define Letter option. { *Name: “Letter 8/2 x 11 inch 15 *PrintableOrigin: PAIR(300,300) Entries within a *Feature or *Option construct define that logical entity, Such as the name, icon representation, and other inherent attributes. The tables below list these entries *Feature: PaperSize { and where they can appear. Some of these entries are related *% rcNameID not redefined. to printing, but they show up in these constructs because * DefaultOption: A4 *% redefine the default papersize. *Option: Letter *% redefine Letter option. they are inherent attributes of a particular Standard feature, or because the designer just felt like it. For example, *Name: “Letter *% redefine name * Printable Area is used in printing, but its values are always *% *PrintableOrigin statement is not *% repeated hence original definition remains Specific to a particular paper size. All generic entries, except *% in effect. 25 *Command:CmdSelect{ } construct, are related to the user interface display.

Entry Name Description Location Comments *FeatureType Constant (DOC PROPERTY, Any custom Required for custom features. JOB PROPERTY, Feature The setting for a PRINTER PROPERTY), the construct DOC PROPERTY feature is association type of a feature. typically saved with a document, while the setting for a PRINTER PROPERTY feature is save in the user's registry on per printer instance basis. JOBPROPERTY features are set per job and hence not saved anywhere. Note that in NTS.0, JOB PROPERTY features are treated in the same way as DOC PROPERTY features. Predefined features default to DOC PROPERTY except for Memory and PageProtection which default to PRINTER PROPERTY. *DefaultOption Symbol, the symbolname of the Any Feature or Optional. If missing, the first default option for the feature. case option is used as the default. (dependency) construct Name Quoted string, the display name Same as above. Optional. If Name is missing, for a feature or option. then *rcNameID must be present. rcNameID Integer, the Windows string Same as above. Optional. If missing, Name resource ID for a feature or must be present. If localization is option name. important, use *rcNameID instead of Name. Zero is not a valid value for any string resource ID. *ConflictPriority an integer, describing the priority Feature optional. Parser always assigns of a feature when resolving construct only no Synthesized features the highest conflicts. 1 is the highest. dependency priority, PRINTER PROPERTY features next, and DOC and JOB PROPERTY the lowest priority. The ConflictPriority value supplied by the user only orders the member features within these 3 groups. If there are features in a group without a user specified Conflict priority, the parser will assign these features a US 6,825,941 B1 61 62

-continued Entry Name Description Location Comments priority lower than any explicitly specified within that group. *ConcealFrom UI Boolean, if TRUE, this Feature Feature Optional. If missing, assume will not be displayed in the UI. construct only no FALSE. This may be desired if a printer dependency supports only one option for a feature (ie only 300 dpi) and the GPD writer determines it serves no purpose to display a feature a user cannot change. The writer may also create features that are indirectly controlled by other features and macros and are not directly accessible through the UI. * UpdateCuality Boolean, if Quality Macros have a Feature Optional. If missing, assume Macro dependency on this Feature, (that construct only no FALSE. is they are enclosed within a dependency switch construct controlled by this Feature) this value should be set to TRUE. UI will not be updated properly otherwise. *Installable Boolean, whether this feature or Any Feature or Optional. If missing, assume option is installable. When this *Option FALSE, i.e. the feature or option entry is TRUE, the GPD parser construct is always installed. Note that will synthesize a feature which another way of specifying has two options: Installed, and installable features or options is to Not Installed. The default is define them and their associated always Not Installed. When the constraints explicitly. One *Installable keyword appears advantage of explicitly defining within a Feature construct, this the Installable features is the user feature is referred to as the host may directly specify its priority feature. When the Not Installed and customize the constraints. option of the synthesized feature is selected, all options of the host feature except the first are disabled via Constraints. When the Installed option is selected, all options of the host feature are enabled including the first. When the Installable keyword appears within an *Option construct, this Option is referred to as the host option. When the Not Installed option of the synthesized feature is selected, the host option is disabled via *Constraints. When the Installed option is selected, the host option is enabled. The display name for the synthesized feature must be defined via InstallableFeatureName or *rcInstallableFeatureNameID. The display names for the two options must be defined via *InstalledOptionName/ *NotInstalledOptionName or *rcInstalledOptionName/ *rcNotInstalledOptionNameID. The parser will also synthesize the constraints needed to implement the behavior described. InstallableFeatureName Quoted string, the display name Same as above. Optional. If it is missing and for the UI control which allows *Installable? is TRUE, then the user to specify the install *rcInstallableNameFeatureID status of the host feature or must be present. option. *rcInstallableFea Integer, the Windows string Same as above. Optional. If it is missing and tureNameID resource ID for string *Installable? is TRUE, then corresponding to InstallableFeatureName must be InstallableName. present. *HelpIndex Integer, the custom help index Same as above. Optional. If missing, no custom corresponding to this help text for this feature/option. feature/option. The index is If it is specified, then *HelpFile US 6,825,941 B1 63 64

-continued Entry Name Description Location Comments referring to the file specified in entry must be present too. Note: *HelpFile entry. 0 and (DWORD)(-1) are not valid values for *HelpIndex. *rcco) Integer, the Windows RC ICON Any Option or Optional. If missing, no icon resource ID for a feature or case image is displayed. option in the associated resource (dependency) DLL. construct *OptionID Integer, the ID value that will be Same as above. Optional. Can only be used for reported in the devmode for this user-defined options (where the feature when this option is ID's are above 256 and by default selected. are assigned by the parser). Can only be used for these features: Halftone, PageSize, InputSlot and Mediatype. The value supplied must not conflict with any other ID value for this feature whether defined via OptionID or supplied by the parser. To avoid problems, use values >512. User assigned OptionIDs are also allowed for any Resolution option. However they must be negative and smaller (more negative) than RES ID IGNORE, currently defined as -200. If OptionID is defined, the ID is stored in the Devmode and the driver will attempt to find an option with the same OptionID value instead of the same DPI. *rcPromptMsgID Integer, the Windows string Same as above. Optional. If missing, assume no resource ID for the prompt prompting is needed, which is the message to be displayed if the most common case. This entry is option is selected. used mostly for prompting to insert paper when Manual Feed is selected. *PromptTime Constant(UISETUP, Any Option Required if the *rcPromptMsgID PRTSTARTDOC), when to construct. entry is present. If there are display the prompt message, multiple prompt messages at either at the driver UI when the PRTSTARTDOC, they are user selects the option or at merged into one for display. The printing when the job is started. only user option is to hit the OK button in the message dialog. *DisabledEeatures LIST(FeaKeyword1, Any Option Optional: If missing, assume all FeaKeyword2, ...) a list of one construct. Features enumerated in the GPD or more Feature Keywords file are available unconditionally. specifying Features which are Note also that any Feature that disabled if the current option is appears within a selected. The keyword may be *DisabledEeatures cannot make nested within switchfease use of the Installable? Keyword. constructs to express more One must explicitly define the complex conditions. Unidrv5 installed feature in the GPD file. may use this information for For example if Duplexing is example to simulate Duplexing, disabled if the “Optional if the printer's duplexing option Duplexing Unit is not installed is not installed, and to publish the and consequently Duplex is printer's current capabilities in desired to appear as a the Directory Services. Disabled Features, one must define an “Optional Duplexing Unit feature with two options “Installed”, “Not Installed. The *Disabled Features: Duplexing entry will appear within the *Option: Notnstalled construct. When one manually defines the installable features be sure to include all necessary Constraints entries. *Command: Construct Any Option Optional. CmdSelect is a CmdSelect{} construct. standard Command construct used to describe how to select a feature setting.

65 Individual features may have additional entries defined option defines dimension related attributes of the printing for their *Feature and * Option constructs. A PaperSize media, Such as the physical paper dimensions, the printable US 6,825,941 B1 65 66 area (origin and size), the cursor origin (0,0), etc. All these largest positive 32 bit signed value). Obviously the resource values are defined relative to the PORTRAIT orientation. file does not need to actually contain Such a resource ID. To For example, the standard paper size LETTER has 8.5" emphasize the Special meaning of this value, the GPD writer width (X-axis) and 11" length (Y-axis). If an attribute, such could define a Value macro: as the cursor origin, changes depending on the orientation 5 (Such as on most page printers which can rotate the coor dinate System to fit the logical orientation), the Switch/ * Macros: myMacros * case constructs should be used to express the orientation { dependency though the values must still be defined relative RCID DMPAPER SYSTEM NAME: 0x7fffffff to the PORTRAIT orientation. Additionally for Standard 1O (pre-defined) papersizes, the GPD writer may choose to have then a reference to this value would be the operating System assign the papersize option a Standard *rcNameID: =RCID DMPAPER SYSTEM NAME display name instead of Specifying one via Name or *rcNameID. To default to using the System assigned name, The following are entries that can appear inside *Option omit the Name entry and set *rcNameID: 0x7fffffff (the constructs of the PaperSize feature.

Entry Name Description Location Comments *PrintableArea PAIR(width, height), the Any PaperSize Required for all PaperSize printable width and height (in *Option options except CUSTOMSIZE. master units)relative to the construct Or PORTRAIT orientation no switchfcase matter where this entry construct. For appears. printers which can rotate its coordinate system to fit the logical orientation, this value might be dependent on the orientation setting. *PrintableOrigin PAIR(x, y), the offset (in Same as above Required for all PaperSize master units) of the upper left options except CUSTOMSIZE. corner of the printable area in PORTRAIT orientation relative to the upper left corner of the physical page in PORTRAIT orientation no matter where this entry appears. * CursorOrigin PAIR(, ), the offset of Same as above. Optional. If missing, assume the the cursor (0,0) relative to the For printers cursor origin is the same as the upper left corner of the which can rotate printable origin in any physical page(in master its coordinate orientation. units)in PORTRAIT system to fit the Required for CUSTOMSIZE. orientation no matter where logical The current driver assumes the this entry appears. orientation, this cursor origin wrt the printer itself value is always is unaffected by changing the dependent on papersize. the orientation setting. *MinSize PAIR(minX, minY), the CUSTOMSIZE Required for CUSTOMSIZE minimum X and Y dimensions option. option. for the CUSTOMSIZE option (in master units). The X and Y dimensions must be relative to the PORTRAIT orientation. *Max.Size PAIR(maxX, maxY), the Same as above Required for CUSTOMSIZE maximum X and Y dimensions option. for the CUSTOMSIZE option (in master units). The X and Y dimensions must be relative to the PORTRAIT orientation. *TopMargin Integer, the top margin (in CUSTOMSIZE Optional. If missing, assume 0. master Yunit) for any custom option only. size in PORTRAIT orientation. * Bottom Margin Integer, the bottom margin (in CUSTOMSIZE Optional. If missing, assume 0. master Yunit) for any custom option only. size in PORTRAIT orientation. *MaxPrintableWidth Integer, the maximum printable CUSTOMSIZE Required for CUSTOMSIZE width on a printer. It applies option only. option. to all custom sizes supported by the printer. * MinLeftMargin Integer, the minimum left CUSTOMSIZE Optional. If missing, assume 0. margin on a printer. It applies option only. US 6,825,941 B1 67 68

-continued Entry Name Description Location Comments to all custom paper sizes supported by the printer. *CenterPrintable Boolean, whether the printable CUSTOMSIZE Optional. If missing, assume width is centered, i.e. whether option only. FALSE, i.e. the left margin is as the left and right margins defined in MinLeftMargin and should be equal. It applies to the rest of the unprintable width all custom paper sizes is on the right. Note that this supported by the printers. entry is applicable only to CUSTOMSIZE option. *Page.Dimensions PAIR(, ), the physical Any custom Required for non-standard dimensions of a non-standard options of options of PaperSize. paper size (in master units). PaperSize The X and Y dimensions must be relative to the PORTRAIT orientation. *RotateSize Boolean, whether to rotate the Any standard Optional. If missing, assume physical dimensions of a PaperSize FALSE. Note that if this entry is standard paper size in order to options TRUE, than the X/Y physical suit the paper feed method. (excluding dimensions should be exchanged This is typically used by CUSTOMSIZE) regardless of the orientation. printers which feed standard Note that id this is TRUE, the envelopes length-wise since the values in PrintableArea and standard envelope sizes have *PrintableOrigin apply to the smaller width than height. For dimensions after the rotation. example, if this is TRUE for Envi10 (4.125" x 9.5"), then its physical size is 9.5" (width) by 4.125" (height) in PORTRAIT orientation. *PageProtectMem Integer, the printer memory Any PaperSize Required if there is PageProtect required (in KB) for enabling options, or feature. page protection. case construct

The following are additional entries that can appear inside option constructs of OutputBin feature. 35 -continued

Entry Name Description Location Comments Entry Name Description Location Comments tion (if present) must precede any *OutputOr- BOOLEAN, when a Any OutputBin Optional. If definition derReversed? multi-page document options, or missing, 40 re e prints to this bin, are case construct. assume within *Option or the pages sorted last This is a reloca- FALSE. case constructs. page to first? table global and may appear at the root level. The root level defini- 45 The following are Resolution Option Entries:

Entry Name Description Location Comments * DPI PAIR(, ), the Any Resolution Required. X and Yunits of the options. graphics resolution. *SpotDiameter Integer, the spot diameter Any Resolution Required. value for this resolution. options, or case construct. *Text DPI PAIR(, ), the Any Resolution Required. Note that DPI X and Yunits of the text options. values must be a power of 2 resolution. Device fonts and factor of *TextDPI values. For vector graphics are printed example, if *TextDPI is in the text resolution. (300,300), then DPI: (75.75) is valid, but *DPI: (100,100) is not since 300/100–3 which is not a power of 2. *PinsPerPhysPass Integer, the number of Any Resolution Optional. If missing, assume 1. scanlines printed when the options, or printhead moves across the switchfcase page. It must be 1 if construct. US 6,825,941 B1 69 70

-continued Entry Name Description Location Comments *OutputDataFormat (defined in Section 5.2.2) is H BYTE, or multiples of 8 if *OutputDataFormat is V BYTE. *PinsPerLogPass Integer, the number of Same as above. Optional. If missing, assume 1. scanlines printed in one By definition, PinsPerLogPass logical pass. On some serial must be in multiples of printers, scanlines are *PinsPerPhysPass value. interlaced to increase the printing resolution. RedDeviceGamma Integer, red gamma to be Same as above Optional. If missing, assume - applied to correct for device 1 to use internal default. color. This is only valid Specify value as gamma value when ICM is disabled. * 1000 with a valid range of 0 to 65535. *Green DeviceGamma Integer, green gamma to be Same as above Optional. If missing, assume - applied to correct for device 1 to use internal default. color. This is only valid Specify value as gamma value when ICM is disabled. * 1000 with a valid range of 0 to 65535. BlueIDeviceGamma Integer, blue gamma to be Same as above Optional. If missing, assume - applied to correct for device 1 to use internal default. color. This is only vali Specify value as gamma value when ICM is disabled. * 1000 with a valid range of 0 to 65535. * RequireUniDir? Boolean, whether this Same as above Optional. If missing, assume resolution requires uni FALSE. This is used only by directional printing be some dot-matrix printers. turned on before sending raster data. * MinStripBlankPixels Integer, the minimum Same as above Optional. If missing, assume 0. threshold for stripping blank Note that this value is used pixels in the middle of only if *StripBlanks (defined scanlines. That is, it applies later) lists ENCLOSED. to stripping enclosing blanks only. The measurement is in bytes. If stripping leading and trailing blanks are requested, the minimum threshold is always 0.

40 The following are additional entries that can appear in any ColorMode option. -continued Entry Name Description Comments 45 *ColorFlaneOrder LIST(YELLOW, Required if Entry Name Description Comments MAGENTA, CYAN, *DewNumOfPlanes is *Color Boolean, whether this Optional. If missing, BLACK, RED, greater than 1. mode produces color assume TRUE if GREEN, BLUE), the (vs. monochrome) *DrvBPP v 1. For gray order of sending color output. scaling on the printer, this 50 plane raster data. A option should be set to color value may be re FALSE even though peated in the list. *DevBPP is greater than 1. *PaletteSize Integer, the number of Optional. If missing, * DevNumOfPlanes Integer, the number of Optional. If missing, entries in the palette assume 2. color planes in color assume 1 plane. For color defined by CmdSelect data sent to the devices, if this entry is 1, 55 of this ColorMode printer. we call it "pixel mode. option. *DevEPP Integer, the number of Optional. If missing, *PaletteProgram Boolean, whether the Optional. If missing, bits per pixel in color assume 1 bit per pixel. For mable color palette is assume FALSE. data sent to the color devices, if this entry programmable. IF TRUE, Driver will printer. is 1, we call it “planar download the correct mode. 60 palette, for INDEXED *Raster Mode Constant (DIRECT, Optional. If missing, RasterMode. INDEXED), which assume INDEXED, i.e. the *Dry BPP Integer, the number of Optional. If missing, describes how the color data sent to the printer bits per pixel for the assume 1 bit per pixel. Note raster data will be is dependent upon the driver's bitmap ren that the driver's rendering interpreted by the printer's palette. dering buffer. The format is always 1 plane. printer in this color 65 legal values are: 1, 4, mode. 8, 16, 24, 32. The bit US 6,825,941 B1 72

-continued Entry Name Description Comments Entry Name Description Comments map format is the 5 * MemconfigKB PAIR(), a * MemconfigKB entries, *IPCabackID Integer (positive), the Optional. If missing, memory configuration each represents a possible callback id for calling assume that there is no expressed in KB unit. memory configuration and OEMImageProcessing additional OEM image pro The GPD parser will syn- they are presented to the after rendering is done cessing on the banding thesize a name in the user in the order listed in and before sending bitmap buffer. 1O form “zinstalledkB> the GPD file. Note: if the data to the printer. KB for UI display. For synthesized name is not example, for PAIR(512, appropriate due to localiza 370), the parser creates tion issues, then the options the name “512KB. should be explicitly Note that the Unidrvis of the instant invention has built-in enumerated using Support for following color data formats 15 * MemoryConfigKB. * MemconfigMB PAIR(, Same as above. (*DevNumOfPlanes/*DevBPP): ), a * MemconfigKB and memory configuration * MemconfigMB can be 1 plane/1 bpp (B/W) expressed in MB unit. used together in any 3 planes/1 bpp (either RGB or CMY) The GPD parser will syn- order desired. thesize a name in the 4 planes/1 bpp (CMYK) form “zinstalledMB> MB” for UI display. For 1 plane/8 bpp example, for PAIR(16, 1 plane/24 bpp 15), the parser creates If other color data formats are specified, the callback the name “16MB. function OEMImageProcessing must be provided. 25 The shorthand and longhand methods of Specifying the The driver's bitmap rendering format can be “deeper” memory configuration may be freely mixed within the than the printer's color data format, which implies that the Memory feature construct. The Synthesized name is also the driver or the OEM-supplied DLL would need to halftone the key name of the option and may be referenced by the image down to the format appropriate for the printer. For * Default Option keyword. The list of synthesized memory example, if one would want the driver to render in 24 bpp options are displayed in the UI along with the long hand format but send YMCK data to the printer, one of the options in the order they appear in the GPD file. ColorMode option should be like: Halftoning is used to reduce the data depth. There are four types of Halftone options. First is the system-provided 35 standard halftone options. They are identified by the stan dard option names in the GPD file. Second, there are the *Feature: ColorMode OEM-provided halftone patterns. These custom options { need additional entries to describe the size and content of the *Option: 24toYMCK pattern (see the table below). If these patterns are stored in { 40 the resource dll they can be either encrypted or unencrypted. * Name: “Photographic Quality *DryBPP: 24 If the patterns are not in the resource dll or they are *DewNumOfPlanes: 4 encrypted, there must be a callback function to generate the *DevEPP: 1 halftone pattern. All OEM provided halftone patterns must have a size that is a multiple of dwords (evenly divisible by 45 4). If the custom pattern has three different patterns each individual pattern must be a multiple of dwords. Multiple pattern resources are assumed to be Stored with the red pattern first, then green and finally blue. Third, are the There are two ways to describe possible memory con OEM-provided callbacks for halftone. There can be multiple figurations on a printer with the instant invention. First, one 50 callback halftone methods and UnidrV5 will pass the sym could enumerate each and every possible configuration bolname of the Selected halftone option when making the using the Standard Option construct. Each option represents callback OEMImageProcessing. The callback halftoning is a possible configuration and the driver will display them as applied on the banding bitmap buffer after all rendering is a drop-down combobox. Within a Memory option construct, done and before Sending data to the printer. And finally, there the following entry must be used to describe the memory 55 is Halftoning on the printer. This is the only type of options configuration: that has *Command:CmdSelect{ } construct for selecting a particular halftone method on the printing. * MemoryConfigKB: PAIR(

*TTFontName: “Arial Entry Name Description Comments *DewFontName: “Arial *rcCartridgeNameID Integer, the Windows Required, unless string resource id for CartridgeName entry { the font cartridge is specified. *TTFontName: “Times New Roman ale. *CartridgeName Quoted string, the font Required if 1O *DewFontName: “Times New Roman cartridge name. *rcCartridgeNameID *TTFS: CourierNew is not specified. { Fonts LIST(integers), the list Required unless *TTFontName: “Courier New of RC FONT re- PortraitFonts andfor *DewFontName: “Courier New source ids for * LandscapeFonts are 15 cartridge fonts which specified. *TTFS: Wingdings are available in both { Portrait and Land *TTFontName: “Wingdings” scape modes. Prefer *DevFontName: “Wingdings” ably all RC FONT IDs in a resource DLL are contiguous and start from 1. *PortraitFonts LIST(integers), the Optional. If missing, The user can modify the font Substitution table through list of RC FONT re- assume none. If Fonts is the driver UI. The GPD file can specify if TrueType font source ids for the specified, then the list of substitution should be used by default or not via the follow Portrait mode fonts in Portrait fonts is the union ing entry: this cartridge. of both entries. 25 * LandscapeFonts LIST(integers), the Optional. If missing, list of RC FONT assume none. If Fonts is *TTFSEnabled: of a string defined directly in the GPD file. *TTFontName: “&TT font name> GPD feature and option Selections are normally indepen DevEontName: “&Substituted device font name> dent of each other. That is, whether option A is installed or 45 Selected has no impact on whether option B can be installed or Selected. However, there are printers where 2 or more Each *TTFS construct defines one substitution prefer feature Selections conflict or constrain each other. One ence. They are concatenated together for displaying in the common case is that if the envelope feeder is Selected, then UI. If two or more *TTFS constructs have the same regular paper sizes, Such as Letter and A4, cannot be Symbolname, the last one overwrites the previous ones. The 50 Selected. This Section defines ways to describe various types font name strings are specified either in UNICODE or in the of constraints. code page specified by CodePage. GPD defines *Constraints entry to express the mutually Each TrueType font can be mapped to at most one device exclusive Selection relationship between two options. For font. In addition, the Substitution happens only if other 55 example, on an Epson Stylus color printer, the 720 dpi attributes match, Such as the character Set, weight, italic, resolution cannot be selected if either Coated360 or Trans orientation. Typically, font Substitution Speeds up printing parency media is Selected: by reducing the amount of data sent to the printer (no font downloading) and reducing the usage of printer memory. Note that device TrueType fonts should be viewed as dif 60 ferent fonts than the system TrueType fonts. For example, *Feature: Resolution HP LaserJet 4 printer has Arial font on the printer, but it is different than the Arial font on the Windows systems both in *Option: 720dpi { terms of the font metrics and the Set of glyphs contained in *DPI: PAIR(720,720) the font. However, for the same glyph index, the outline data 65 *Constraints: MediaType.Coated360 is the same. So for better performance, its GPD file can *Constraints: MediaType. Transparency define a default Substitution table: US 6,825,941 B1 77 78 Separate constraint. Each InvalidCombination entry is inde -continued pendent of another and they may or may not have common options. * Constraints are a special case of InvalidCombi nation involving only two options where one Qualified Name is implied from the location of the * Constraints entry within a particular *Feature/* Option construct. The above Con Another way to look at it is that if 720 dpi resolution is straints example for 720 dpi resolution can also be described selected, then neither Coated360 media nor Transparency S. media can be selected. Within the same *Feature or *Option construct, the relationship between multiple * Constraints 1O *InvalidCombination: LIST(Resolution.720 dpi, MediaType entries is the logical OR. .Coated360) The * Constraints definitions are reciprocal. That is, if A is constrained by B, then B is automatically constrained by A. *InvalidCombination: LIST(Resolution.720 dpi, MediaType. Trans In the above example, if 720 dpi resolution is selected, then parency) the user cannot Select either Coated360 paper or Transpar 15 Because they are more symmetric, InvalidCombination ency. On the other hand, if the current resolution is 360 dpi entries tend to be more efficient to evaluate than Con and the user has selected Coated360 or Transparency media, Straints. then the user can no longer select 720 dpi resolution. The Most printers have two types of options: baseline and location where the constraints are specified is up to the GPD installable. The most common installable options are addi creator. It is okay to define the constraints in both Resolution tional input bins and the duplexing unit. Occasionally, the and MediaType constructs, but it is redundant. option installations are mutually exclusive. For example, if When an option is associated with multiple constraints, the optional envelope feeder is installed, then the duplexing GPD allows using the LIST value type to consolidate them. unit cannot be installed, and vice versa. Both Constraints For example, the above constraints can be described in one and InvalidCombination deal with impossible combina entry: 25 tions of explicitly Specified option Selections. Features Syn *Constraints: LIST(MediaType.Coated360, MediaType. Transpar thesized by the Installable keyword are not affected by ency) * Constraints and InvalidCombination since they have no Qualified Name. So GPD defines an entry, Here is the ENBF definition of * Constraints entry: * Invalid Installable Combination, to express constraints ::=*Constraints: LIST({, }) LIST({,}) ::=. 35 Note that each qualified name in the list must be an install Note that * Constraints definitions are not transitive, that able option or feature, i.e. the corresponding Option or is, if A is constrained by B, and B is constrained by C, then *Feature construct must contain the following entry: A is not automatically constrained by C. Obviously, *Con Straints definitions must appear inside an Option construct *Installable: TRUE because the construct itself implies the one party of this 40 mutually exclusive Selection relationship. The InvalidInstallableCombination keyword means the Sometimes, the Selection constraints involve more than Synthesized Features hosted by the Installable Features or two options. For example, on an Epson Stylus color printer, Options enumerated in the Qualified Names cannot all be set the CMYK color mode cannot be used with the plain paper to the “Installed' option. If the QualifiedName refers to an in 720 dpi, but it can be used with Coated 720 paper in 720 45 installable Feature, there is obviously no option qualifier So dpi or used with plain paper in 180 dpi. In addition, the plain in this case: paper and 720 dpi resolution are compatible if the B/W mode is selected. To describe Such multiple-option ::= constraints, GPD defines InvalidCombination entry: 50 An installable feature means that all options of the feature ::=* InvalidCombination: are installable except the first option. Just like LIST({}) * InvalidCombination, each InvalidInstallableCombination This entry must appear at the root level Since it is entry is independent of another. The exclusive installation Symmetric with respect to each of the enumerated Quali relationship is Symmetric among the Synthesized features fied Names. So the above example can be described as: 55 implied in the list. Note: the InvalidInstallableCombination *InvalidCombination: LIST(Resolution.720 dpi, MediaType. Plain, keyword can only be used if the Installable'? Keyword is ColorMode. CMYK) present in the GPD file. There is the implicit constraint that if an option is not For the expression installed, then it cannot be selected. It is also possible to *InvalidCombination: LIST(option1, option2, option3, 60 have constraints between one option being installed and a option4, . . . ) different option being Selected, Such as if A is not installed, then B cannot be selected; or if A is installed, then B cannot the logical meaning, in terms of option Selection, is be selected. For example, if LargeFmt tray is not installed, (option 1 & & option2 && option3 && option4 &&. . . . ) then Tabloid paper cannot be selected. GPD treats these 65 types of installation-constraints-on-Selection as attributes of More than one InvalidCombination entry may appear in an installable option or feature. It defines following new the GPD file. Each InvalidCombination entry defines a entries: US 6,825,941 B1 79 80 ::=*NotInstalledConstraints: ::=*InstalledConstraints: , for *Installed Constraints, the implied member is . These keywords are unnecessary if there are no synthesized Features present Since the Constraints keyword can then explicitly refer to all the features. The following table Summarizes various types of con Entries that can appear inside Switch and case con Straints: Structs are called relocateable entries. They include all global entries unless explicitly Specified otherwise. 25 Examples include: * DeviceFonts, *TTFSEnabled. They also include most entries within a *Feature construct or within a then B cannot be installed then B cannot be selected * case construct. The designation is based on whether it is If A is not N/A *NotnstalledConstraints applicable or not, and it is enforced by the GPD parser. For installed, example, * Constraints entry is not relocateable. If A is in- InvalidInstallableCombination Installed Constraints Additionally, FontCartridge, * Command constructs are stalled but relocateable. The Switch and * case constructs nested inside not selected, If A is this is equivalent to the case *Constraints, or an Option construct defines the additional dependency on selected, where “if B is installed, then A InvalidCombination top of the implicit dependency. Each Switch construct cannot be selected', i.e., using Specifies one dependent feature. The only legal entry within InstalledConstraints inside B's 35 a * Switch construct is case construct type. It is not required construct. to have one case construct for every option of the depen dent feature. The overwriting rule may be used when appli GPD defines the switch and * case constructs for express cable. Within a case construct, there can be nested Switch ing dependencies between entry values and Specific printer constructs for expressing multiple dependencies. configurations. The Switch and * case constructs are similar 40 Just like C language, GPD defines a special case option, to the Switch and case Statements in C programming lan called * default, for expressing all other valid options not guage. It should be noted that although the documentation explicitly mentioned. An option is valid if it is not con refers only to the lowercase version, the Parser will also Strained by the current installations and Selections. That accept Switch and Case. The * Switch construct names the means the Set of valid options may change depending on the dependent feature and the case construct names the Specific 45 Specific printer configuration. If a default case is not option of that feature. For example, on HP LaserJet 4L present, either all possible options have been explicitly printer, the *Printable Area, Printable Origin and * Cursor enumerated or the value has been initialized before the Origin attributes, which are members of the PaperSize * Switch/* case constructs. option construct, also depend on the logical orientation: Global entries can take advantage of the implicit depen 50 dency imposed by the Feature and * Option structures. But when a global entry is used within an Option construct, its name must be prefixed by the reserved word EXTERN *%. All numbers are expressed in 600dpi unit. *Feature: Orientation GLOBAL: to distinguish it from native members of that { COnStruct. *DefaultOption: Portrait 55 For example: *Option: Portrait { *Name: “Portrait *rcIconID: =RC ICON PORTRAIT *Option: UPPERBIN *Option: Landscape CC90 { 60 Name: “Upper OutputBin' *Name: “Landscape' EXTERN GLOBAL: *OutputOrderReversed?: TRUE *rcIconID: =RC ICON LANDSCAPE

*Feature: PaperSize Note that * Default Option entry can also appear inside a { 65 * Switch/case construct, but there cannot be any loop in the *DefaultOption: Letter dependency chain. For example, if the default option of Feature A depends on Feature B, then the default option of US 6,825,941 B1 81 82 Feature B cannot depend on Feature A. There can be user to Select a “draft quality' when Speed of output is more multiple features on the dependency chain, but the default important than quality, a “Better quality”, and a “Best option of the last one on the chain cannot depend on any quality”. The quality macro keywords allow the GPD writer other feature. When Specifying the dependency of an attribute, it must to associate one or more Feature Settings with each of these be done consistently. When there are multiple levels of UI buttons. When the user presses one of the quality buttons, dependency, the same feature can appear only once at only each of the Features associated with this button are set to the one level. That is if an attribute is defined to be dependent option specified in the GPD without further user interven on Feature A at the first level, it cannot have a dependency tion. The quality macro keywords are: on Feature A at any other level. For example say the attribute represented by the DeviceFonts keyword had dependencies *DraftOualitySettings: LIST(qualified name1, qualified name2,... on Orientation and Resolution. The following would be an ) inconsistent (nonsensical) way of expressing this depen dency. * BetterQualitySettings: LIST(qualifiedname1, qualified name2,... 15 )

switch: Orientation *BestOualitySettings: LIST(qualified name1, qualifiedname2,...) { * case: PORTRAIT *DefaultOuality: one of the following: “DRAFTQUALITY, { switch: Resolution “BETTERQUALITY, “BESTQUALITY} { *case: 300dpi As defined previously a Qualifiedname is defined to be of the { form *switch: Orientation *% Orientation appears at 2 *% nesting levels - inconsistent and meaningless! 25 ::=.

*Switch: ColorMode 40 If any attribute is defined multiple times within the GPD case: 24bit file, all of the definitions must express dependencies on the *switch: MediaType Same Features at each nesting level. For example, if an case: CLAYCOATED attribute is initially defined to have a dependency on Ori { entation at the first level and Resolution at the second level, 45 *DraftOualitySettings: LIST(qualified name1, a Subsequent definition of that attribute cannot specify a qualifiedname2,...) * BetterQualitySettings: LIST(qualifiedname1, dependency on Papersize at the first level and Orientation at qualifiedname2,...) the Second level. However, more dependency levels can be *BestOualitySettings: LIST(qualified name1, added in Subsequent definitions of that attribute as long as qualifiedname2,...) the existing levels remain consistent with the previous 50 *DefaultOuality: BESTQUALITY definitions. One may think of each attribute being repre case: GLOSSY sented by a multi-level tree. The initial definition may define { the trunk and lower branches, Subsequent definitions may *DraftOualitySettings: LIST(qualified name1, add more lower branches or define Smaller branches off the qualifiedname2,...) * BetterQualitySettings: LIST(qualifiedname1, existing branches, but may not redefine the branching Struc 55 qualifiedname2,...) ture that has already been defined. One may however *BestOualitySettings: LIST(qualified name1, redefine the value of the attribute (the leaves of the tree). qualifiedname2,...) Note there is no requirement that the tree be symmetric. If *DefaultOuality: BETTERQUALITY an attribute has further dependencies on resolution for *default: landscape orientations but none for portrait, there is no need 60 { to add more switch/* case constructs into the portrait branch *DraftOualitySettings: LIST(qualified name1, Simply because the landscape branch needs them. qualifiedname2,...) * BetterQualitySettings: LIST(qualifiedname1, A GPD writer may want to implement an ease-of-use UI qualifiedname2,...) feature which in its current implementation presents 3 radio *BestOualitySettings: LIST(qualified name1, buttons that allow the user to control the quality of the 65 qualifiedname2,...) printed output without having to specify all of the options *DefaultOuality: DRAFTQUALITY which affect the output quality. The three buttons allow the US 6,825,941 B1 83 84 should explicitly define that unused macro by an empty list: -continued LIST(). Simply omitting one of the QualityMacro entries may lead to unanticipated behavior, (the parser's idea of the default value for the undefined macro may not agree with the GPD writee's idea of the default value). The GPD writer * default: should also ensure all 4 keywords are defined for all com { *DraftOualitySettings: LIST(qualifiedname1, qualified name2, binations of ColorMode and MediaType to prevent UI inconsistencies. Use the * default: keyword within a switch * BetterQualitySettings: LIST(qualified name1, qualifiedname2, construct as shown above to ensure a definition always exists. *BestOualitySettings: LIST(qualified name1, qualifiedname2, *Command is a grouping construct used to describe *DefaultOuality: DRAFTQUALITY printer commands Such as ejecting the page or Selecting a 15 font. The following are the legal entries within a * Command construct. Note that none of them can appear directly inside * case constructs.

Entry Name Description Location Comments *Cnd Quoted string, the command string Any *Command Required, unless *CallbackID for this command construct entry is defined. *CallbackID Integer (positive), the unique Same as above. Required, unless Cmd entry callback id for this command. is defined. Params LIST(). Same as above. Optional. This entry can be The standard variable names are used only with CallbackID defined above. This allows callback together. Cmd entry commands to access certain cached references the standard values such as the current variables directly in its resolution. command string. *NoPageEject? Identifies a subset of Command constructs Optional. Default is FALSE DOC SETUP commands which with an Order section = have the property that when all of DOC SETUP the commands in the subset are Currently used only emitted in the specified order, the if the printer state of the printer will change as supports Duplexing. directed. This subset of commands when emitted does not have side-effects, they do not change/reset any other configuration of the printer that is not explicitly specified in the subset of commands. (they form a sub-group). Also these commands have the property that when the entire subset is emitted between the first and second pages when printing in Duplex mode, no page ejection occurs. *Order

.

50 Note: to prevent inconsistent (bizzare) UI behavior, the A printer command in GPD can be used to configure the quality macroS Should be defined So the execution of that printer, change the printer State during printing Such as macro will not have the Side effect of changing either the moving the cursor, and Select printer options Such as Portrait MediaType or the Color Appearance Settings. It is acceptable orientation or Letter paper size. For the first two types, each to have a macro change the color mode option-for example 55 command has a unique symbolname and all Symbolnames If Color Appearance=Color, the Best Quality macro may Set are pre-defined. These Command constructs must appear at ColorMode=24 bpp, the BetterOuality macro may set the root level or inside case constructs. But for Selecting ColorMode=8 bpp and the Draft Ouality macro may set printer options, the Command construct must have the ColorMode=4 bpp, but it would not make sense to set 60 Symbolname CmdSelect and the construct must appear ColorMode=1 bpp (Mono). The feature settings defined for inside the corresponding Option construct. a quality macro should obviously be compatible with each other and not violate a Constraints or InvalidCombination For simple commands that require only the command Statement. If quality macroS are used, all three macroS and String, GPD provides a special Shorthand Syntax: the DefaultOuality keyword should be defined. If the GPD 65 writer does not want to implement one of the macroS, for one or more combinations of MediaType or ColorMode, he *Command:: US 6,825,941 B1 85 86 For example, -continued *Command: CmdXMoveAbsolute: “escape for moving cursor horizontally to an absolute position' is equivalent to: *Feature: Resolution { *DefaultOption: 360dpi *Option: 360dpi *Command: CmdXMoveAbsolute { *Name: “360 dpi x 360dpi” *Cmd: “escape for moving cursor horizontally to an absolute position *Command: CmdSelect { * Order: DOC SETUP.70 *Cmd: “-1Bs (da020001s” To configure and control a printer properly, the commands 15 must be sent in the correct order. The ordering information has two parts: the job Section name and the Sequence number within a Section.

*Order:

.nk01>r” has no effect. Essentially, the GPD file determines what can be changed by ResetDC. US 6,825,941 B1 87 88 One Special category of commands that always require the N: Canon integer encoding. Outputs most significant byte to ordering information is the printer configuration commands. least Significant byte encoding as follows. The least 4 They work together with the printer option Selection com significant bits are encoded as 001.sbbbb, where s repre mands to configure the printer. All of them are optional. Sents the sign of the integer (0 is negative, 1 is positive), and b represents a significant bit of the integer. The next most significant 6 bits are encoded as 01bbbbbb. So the Configuration integer 254 (11111110) would be represented as Command Description (01.001111 00111110). CmdStartJob Initialize a job stream. V: NEC VFU (Vertical Format Unit) encoding. The param CmdStartDoc Initialize a document. eter specified by this format is divided by a /6 inch and CmdStartPage Initialize a page for printing. This initialization VFU data will be sent to a printer same number of times command should also set the printer's cursor posi as the quotient. tion to (0, 0) in cursor coordinates. CmdEndPage Finish a page after sending down all drawing objects If a parameter value has limits (minimum and maximum), CmdEnd Doc Finish a document they can be expressed inside a pair of Square brackets CmdEndJob Complete a job stream 15 CmdCopies Set the count for multiple-copy printing immediately following the format letters. CmdSleepTimeOut Set the number of minutes in idle mode before the The parameter value is enclosed by a pair of curly printer goes into sleep mode (i.e. power-save mode). brackets immediately following the limit specification (if any). There is a set of pre-defined values that GPD com Take Canon BJC-600 for an example: mands can reference at any time, Such as the current resolution (xdpi, ydpi), the current paper width and height, etc. These values are expressed in the master units if applicable. A GPD command can use a restricted arithmetic *Command: CmdStartDoc expression (+,-, /, *, mod, max repeat, min, max) to express * Order: DOC SETUP.10 25 how to manipulate these values. All calculations are done in *Cmd: “41B-K-0200000F1B>(ak0100011B>(c40300115.” unsigned integers and intermediate results cannot overflow a DWORD (32-bit). Normally, if the result of evaluating the parameter expression is a value which exceeds the Specified A GPD command String is a byte Sequence which, when max limit, the command will be emitted once with the max Sent to the printer, performs a Specific pre-defined function, Specified value. The operator “max repeat” modifies this Such as Selecting a paper size or positioning the print head. behavior, causing the entire command invocation to be There is no restriction on the length of a command. It is basically a quoted String but with Special provisions for emitted repeatedly using the max allowed value until the Specifying parameters. For example, an absolute-X-move accumulated value is equal to the evaluated value. command needs a parameter for Specifying the target X 35 Obviously, this is applicable only to Single-parameter com position. A parameter must be specified outside of the pair mands. Parenthesis can be used to impose precedence. of double quotes and is treated by the parser as a placeholder Otherwise, it follows the C convention on the precedence of for one string segment (whose content will be determined arithmetic operators. A parameter Segment can croSS line when the command is actually emitted). I.e. all the String boundaries using the Standard line continuation character Segments and parameter constructs are concatenated to form 40 +. Continuation linebreaks may only be inserted where the InvocationString. At run-time, UnidrV5 evaluates the whitespace is permitted. No whitespaces are permitted expressions defined in the parameter construct and emits the between the digits comprising an integer, the characters of a result in the Specified format in place of the parameter variable name, or other token like "max repeat”. COnStruct. The EBNF definition for a GPD command string is as The escape letter 76 introduces a parameter Segment. follows (to avoid confusion, reserved letters are underlined The letters immediately following "% specify the format of 45 and in bold, and reserved words are in bold). the parameter value. The following table lists the standard formats Supported: digitsd: Parameter as signed ASCII decimal number. }) 50 ::= digitsD: Parameter as signed ASCII decimal number. + Sign is printed if parameter is greater than 0. ::= C: Parameter as byte. *{ C: Parameter+0 as byte. ::= < { }> f: Parameter as unsigned ASCII decimal number with the ::= { ::= M: Parameter as word, MSB first. ::= max repeat (). G: 2* abs(Parameter)+is negative(Parameter) as based 64 ) number, least Significant digit to most significant digit. max() The most significant digit (0–63) is represented by the ( ) bytes 191-254. All other digits are represented by the 65 ( ) bytes 63-126. “is negative(Parameter)" is 1 if Parameter is negative, 0 otherwise. US 6,825,941 B1 89 90 Parenthesis are optional around expressions involving -continued will be evaluated before left to right. Note that and are expressed in the unit that the actual options are listed in the following table. They are of DWORD type unless specifically noted otherwise.

Standard Variable Name Description Scope NumCfDataBytes number of data bytes When the driver is sending CmdSendElockData or CmdSendXXXData where XXX is any of the 7 non-white primary color. If there is compression, this is the number of compressed data bytes. RasterDataWidth InBytes the width of scanlines in bytes When the driver is sending CmdSendElockData or CmdSendXXXData where XXX is any of the 7 non-white primary color, or CmdSetSrcBmpWidth. Compression has no impact. RasterDataHeightInPixels the height of the raster data block in When the driver is sending pixels. CmdSendElockData or CmdSendXXXData where XXX is any of the 7 non-white primary color, or CmdSetSrcBmpHeight. NumCfCopies number of copies requested by the When DrvEnablePDev andfor Se. SETCOPYCOUNT escape is called. PrintDirInCCDegrees he requested rotation degrees When the driver is sending (counter-clockwise). CmdSetSimpleRotation or CmdSetAnyRotation command. DestX he destination X cursor position (in When the driver is sending master X unit) Relative to the cursor CmdXMoveAbsolute or origin X. CmdYMoveAbsolute command. DestY he destination Y cursor position (in Same as above. master Yunit) Relative to the cursor origin Y. DestXRel he destination X cursor position When he driver is sending relative to the current X cursor Cmd MoveRelLeft or position (in master X unit). Cmd MoveRelRight command. DestYRel he desired Y cursor position relative Whe he driver is sending o the current Y cursor position (in Cmd MoveRelUp or master Yunit). Cmd MoveRelDown command. LinefeedSpacing he amount of vertical spacing a When the driver is sending inefeed command (CmdLF) should CmdSetLineSpacing command. generate (in master Yunit). RectXSize he width of the rectangle in master X When the driver is sending unit. CmdSetRectWidth command. RectYSize he height of the rectangle in master Y When the driver is sending unit. CmdSetRectHeight command. GrayPercentage he gray level (in percentage) of the When the driver is sending rectangle. CmdRectOrayFill command. NextFont) he unique number for the soft font to When the driver is sending be downloaded next. CmdSetFont) command. NextGlyph he double-byte glyph code to be When the driver is sending down loaded next. CmdSetCharCode command. PhysPaperLength he length of the physical paper in When DrvenablePDev is called. master Yunit (in portrait orientation). PhysPaperWidth he width of the physical paper in Same as above. master X unit (in portrait orientation). FontHeight he height of the current device font in When a font has been specified for a he master Yunit. text output call. FontWidth he width of the current device fixed Same as above. pitch font in the master X unit. FontntLeading he internal leading of the current Same as above. device font in the master Yunit. FontBold means the current device font is Same as above. bold and O means otherwise. Fonttalic means the current device font is Same as above. italic and O means otherwise. FontJnderline means the current font style is Same as above. underlined and O means otherwise. US 6,825,941 B1 91 92

-continued Standard Variable Name Description Scope FontStrikeThru 1 means the current device font style Same as above. is strike-through and O means otherwise CurrentFont) he downloading id of the current font when a font has been specified for a text output call and the font is a downloaded font. TextYRes he current text Y resolution. When the user has initiated a print job. TextXRes he current text X resolution Same as above. Graphics YRes he current graphics Y resolution. Same as above. (not implemented in Beta 1) GraphicsXRes he current graphics X resolution. Same as above. (not implemented in Beta 1) CursorOriginX The X printing offset (in the current When DrvenablePDev is called. orientation) in MasterUnits. The printing offset is defined to be the Imageable Origin - the Cursor Origin. CursorOriginY The Y printing offset. When DrvenablePDev is called. Rop3 he current rop3 code When the current DDI call supplies the rop3 code. Red Value Red Value of the color for the palette The scope of this variable is during index being defined. defining Palette using command CmdDefinePaletteEntry. Green Value Green Value of the Color. Same as above. BlueWalue Blue value of the color. Same a above Palette.IndexToProgram The palette entry being programmed. Same as above. CurrentPalettendex The index of the current palette entry When the driver is sending to be selected CmdSelectPaletteEntry and any other command which sets the foreground brush color. Pattern BrushType The type of pattern brush to be When the driver is sending down a downloaded. Predefined types: pattern brush. 2 - Shading pattern 3 - Cross-hatch pattern 4 - User defined pattern PatternBrush.D The ID of the downloaded pattern When the driver selects a brush. downloaded pattern brush as the current brush. Pattern Brush.Size The size in bytes of the pattern brush When the driver is sending down a to be downloaded. pattern brush.

GPD has two types of macros: block macros and value a macroS. AS their names imply, block macroS are used to represent a Sequence of GPD entries and constructs while value macroS are used to represent all or parts of a value. {*BlockMacro: PaperConstraints Ablock macro definition looks like a grouping construct: *Constraints: InputBin.Tray2 45 *Constraints: InputBin.Tray3 *Constraints: Duplex BlockMacro: rate PaperSize { 50 *Option: Env10 { *InsertBlock: =PaperConstraints Ablock macro can be referenced by the special InsertBlock entry: 55 *Option: EnvMonarch { InsertBlock: *InsertBlock: =PaperConstraints

Where is the 2 preceeded by the 'equals'6 s character, without intervening { Option: EnvB5 whitespace. During GPD parsing, the above entry will be *InsertBlock: =PaperConstraints replaced, in place, by the body of the block macro definition without the curly brackets. For example, on HP LaserJet 5, all envelope paper Sizes can not be used with the input bin Tray2 and Tray3, or in Duplex modes. Ablock macro can be 65 defined to describe these common constraints and then use it in every envelope Size option definition: US 6,825,941 B1 93 94 When the above Env10 option definition is parsed, it is first expanded into: -continued Helvetical ID: 23 Courier ID: 24 *Option: Env10 { *BlockMacro: PSOrder { *Order: DOC SETUP.11 } *Constraints: InputBin. Tray2 *DeviceFonts: LIST(=Helvetica ID, =Courier ID, ...) *Constraints: InputBin. Tray3 *Feature: PaperSize *Constraints: Duplex { *Name: “Paper Size” * DefaultOption: Letter *Option: Letter { Arbitrary white Spaces are not allowed between the equals *Name: “Letter 85 x 11 inch sign and the Macroname. If the definition of a block macro *PageProtectMem: 1028 contains curly brackets, the brackets must appear in pairs 15 switch: Orientation { *case:Portrait and in the correct order of nesting. Block macro definitions { may contain other Block macro or Value macro definitions *Command: CmdSelect (macros may be nested to arbitrary depth) and may reference { other BlockMacros or ValueMacros. *InsertBlock: =PSOrder A Value macro definition is a Simple *Cmd: =LetterCmdPrefix “&1B>*cOt5760x768OY : 25 { *Command: CmdSelect ValueMacro1: *cOt7632x588OY *PrintableArea: PAIR(4860, 6360) *PrintableOrigin: PAIR(120, 120) A Macros construct can contain any number of value *CursorOrigin: PAIR(100, 6480) } macro definitions, and there can be multiple MacroS con structs in a GPD file. The is optional and purely for better readability. The ValueMacro name is a 35 and ValueMacro References. After all Val macro must be defined before it can be referenced and a ueMacro references (if any) are resolved, every value macro macro can not reference itself. All nested macro references definition must itself represent a valid value type-for are resolved at the time of parsing the macro definitions. If example an Integer, Quoted String, Symbol, LIST etc. a macro is defined more than once, one definition lasts until There are a few additional restrictions on the arbitrary 45 it is overwritten by the next definition or its Scope expires. character Sequences. First, a may never A BlockMacro is considered defined when the closing curly contain the equals character Since this introduces a Val brace of the BlockMacro construct is parsed. At that time ueMacro reference. Second, if the Double Quote character all macros defined within the BlockMacro are lost. The appears within a , the entire Sub String it Scope of a Macro definition is limited to the nesting level it introduces must also be present including the closing Double 50 was defined in. MacroS defined within a nesting level can Quote. Finally, if the Percent character appears within a only be referenced within that nesting level (or levels outside of a literal SubString, the entire contained within that nesting level). A macro defined at the command parameter construct it introduces must also be Root level can be referenced throughout the GPD file. For present including the closing Curly Brace. example, if we have, AS with BlockMacro references, ValueMacro references 55 are formed by prepending the equals character to the Val ueMacro name. When the ValueMacro reference is resolved, *Macros: DefaultMargins this token is replaced by the fully resolved macro definition. { Here's an example featuring the HP LaserJet 4L printer: HWMargins: RECT(0,0,40,0) *% definition #1 60 *Feature: PaperSize { * DefaultOption: Letter *Option: Letter { *Name: “Letter 8/2 x 11 inch 65 * Margins: =HWMargins US 6,825,941 B1

orientation. Commands describe the Specific printer escapes -continued for a particular task, Such as doing absolute X move, or Sending a block of raster data to the printer. All commands {*Option: A4 are expressed via *Commandis construct or its short-hand *Macros: DefaultMargins *% definition #2 for the same 5 representation if there is no command callback. There is no value macro ordering information in any printing commands and UnidrV5 { Sends the appropriate commands when needed. It may cache HWMargins: RECT(0,0,50,0) certain Settings (Such as the current compression mode) to Name: “A4 210 x 297 mm avoid repeatedly Sending the same command. *Margins:-HWMargins 10 For clarity, all command names start with Cmd prefix. All *Option:*% this Legalclosing bracket un-defines the second definition. printing attri butes appear at t he. root levelevel unless1 thereh IS { dependency on printer configurations, in which case they are *Name: “Legal 8% x 14 inch” inside either the case constructs or the appropriate *Option *Margins: =HWMargins constructs (where their names must be preceded by 15 EXTERN GLOBAL: prefix). GPD loosely divides all printing attributes and commands into four categories. First there is General Printing, which The first definition (#1) is referenced by Letter and Legal includes entries th tt R s R E. S.d optionoptions, and the second definition (#2) is used only by A4 cursorentries movements.that are Specific Next to is raster Kaster graphics Tung. printing. When includesThird is GPD defines a set of attributes and commands for describ- . E. with ill R that are Specific to ing how to compose the printer-ready output data. Attributes OWnloading ion S C CCWCC on prin Ing. provide information about Specific properties, Such as where The following defines the printing attributes and com the cursor X is after Sending a carriage return, or whether the mands by category. printer can rotate raster graphics when printing in landscape General Printing: Printer Capabilities

Entry Name Description Comment *RotateCoordinate? Boolean, which describes whether the printer Optional. If missing, assume can rotate the coordinate system to fit the FALSE, i.e. the printer cannot logical orientation, i.e. whether it has rotate the coordinate system to fit command to set the logical orientation. Note the logical orientation, such as all that if the printer has both LANDSCAPE 90 dot-matrix printers. and LANDSCAPE 270 orientations, then the value of this entry applies to both landscape orientations. It cannot appear inside switchfcase constructs. RotateRaster? Boolean, which describes whether the printer Optional. If missing, assume can automatically rotate the raster data to fit FALSE, such as for all dot-matrix the logical orientation. If RotateCoordinate? printers. entry is FALSE, this entry must be FALSE too. Note that if the printer has both LANDSCAPE 90 and LANDSCAPE 270 orientations, then the value of this entry applies to both landscape orientations. *TextCaps LIST(TC OP CHARACTER, Optional. If missing, assume empty TC OP STROKE, TC CP STROKE, list. Only 90-degree rotation is TC CR 90, TC CR SF X YINDEP, supported for device fonts. TC SA DOUBLE, TC SA INTEGER, TC SA CONTIN, TC EA DOUBLE, TC IA ABLE, TC UA ABLE, TC SO ABLE, TC RA ABLE, TC VA ABLE), list of the printer's text capabilities. These constants map directly to the capability flags defined by Windows. *RotatePoint Boolean, which describes whether the printer Optional. If missing, assume can automatically rotate fonts to fit the logical FALSE, such as for all dot-matrix orientation. If RotateCoordinate? entry is printers. FALSE, this entry must be FALSE too. Note that if the printer has both LANDSCAPE 90 and LANDSCAPE 270 orientations, then the value of this entry applies to both landscape orientations. It cannot appear inside switchfcase constructs. *ReselectFont LIST(AFTER GRXDATA, Optional: if missing assume fonts AFTER XMOVE, AFTER FF) this keyword do not need to be reselected. allows you to specify which operations require the driver to reselect the current font. AFTER GRXDATA means the driver must reselect the font after graphic data is emitted using any of the CmdSendxXxData commands. AFTER XMOVE means the US 6,825,941 B1 97 98

-continued Entry Name Description Comment font must be reselected after X movement commmands. AFTER FF means the font must be reselected after CmdFF (formfeed). * MemoryUsage LIST(FONT, RASTER, VECTOR), which Required if Memory feature is lists what types of items consume printer defined. memory defined in the Memory feature. If a listed type is not applicable, it is ignored. For example, if LIST(FONT, RASTER, VECTOR) is specified and the printer does not support vector graphics, then it is equivalent to LIST(FONT, RASTER).

15 General Printing: Cursor Control

Entry Name Description Comment *CursorXAfterCR Constant Optional. If missing, assume (AT PRINTABLE X ORIGIN, or AT CURSOR X ORIGIN, i.e., CmdCR AT CURSOR X ORIGIN), the will move the cursor X to the physical O cursor X position after sending a position. carriage return. *BadCursor MovenGrxMode LIST(X PORTRAIT, Optional. If missing, assume empty list, X LANDSCAPE, Y PORTRAIT, i.e. no restriction. Y LANDSCAPE), the list of illegal cursor movements in raster graphics mode. For example, X PORTRAIT means X movement is not allowed in raster mode at Portrait orientation. *YMoveAttributes LIST(FAVOR LF, Optional. If missing, assume empty list. SEND CR FIRST), the list of special attributes pertaining to Y move commands. *UseSpaceForXMove? Boolean, can space characters be Optional. If missing, assume TRUE. If used to perform X movements? If TRUE the driver will use SPACES for FALSE, only NULL characters are coarse moves and NULLS for fine used. OWeS. * MaxLineSpacing Integer, the maximum line spacing Optional. If missing, assume Infinite, value (in master Yunit). i.e. there is no limit. *EjectPageWithFF Boolean, whether the printer uses Optional. If missing, assume FALSE. FormFeed to eject a page. *XMoveThreshold Integer (positive), the threshold (in X Optional. If missing, assume 0 master unit) above which threshold, i.e. CmdXMoveAbsolute is CmdXMoveAbsolute is used instead always used. The special value, *, can ofCmdXMoveRelLeft or be used to specify preference for relative CmdXMoveRelRight. This is X-move commands. applicable only if both absolute and relative X-move commands are specified. *YMoveThreshold Same as above except substituting Same as above except substituting “Y” “Y” for “X. for “X. *XMoveUnit Integer (positive). The unit is Required if there is any X-move expressed in dots per inch. For commands (either absolute or relative). example, if the printer's X-move unit is 1/60, then this entry should be 60. Note that the X movement unit must factor evenly into the master X unit. *YMoveUnit Same as above except substituting Same as above except substituting “Y” “Y” for “X. for “X. CmdXMoveAbsolute Quoted string, the command to move Optional. This command can have only to an absolute X position. one parameter which specifies the movement amount. CmdXMoveRelLeft Quoted string, the command to move Same as above. left relative to the current cursor X position. CmdXMoveRelRight Quoted string, the command to move Same as above. right relative to the current cursor X position. CmdYMoveAbsolute Quoted string, the command to move Same as above. to an absolute Y position. US 6,825,941 B1 99 100

-continued Entry Name Description Comment CmdYMoveRelUp Quoted string, le. COllaCO OWe Same as above. up relative to the current cursor Y position. CmdYMoveRelDown Quoted string, le. COllaCO OWe Same as above. down relative to the current cursor Y position. CmdSetLineSpacing Quoted string, le. COllaC O Set Optional. the distance of a line spacing command. CmdCR Quoted string, he command to return Required. the cursor X to he leftmost position (carriage-return). CmdLF Quoted string, le. COllaCO OWe Required. the cursor Y to the next line (line feed). The amount of movement is determined by the current line spacing value. Cnd Quoted string, the command for Required. ejecting a page (form-feed). CmdSetSimpleRotation Quoted string, the command to set Optional. This command can be the rotation angle in multiples of 90 superseded by CmdSetAnyRotation if degrees (counter-clockwise). the printer supports arbitrary-degree rotation. CmdSetAnyRotation Quoted string, the command to set optional. If missing, assume the printer the rotation angle in counter does not support arbitrary angle rotation clockwise direction CmdniDirectionOn Quoted string, the command to Optional. If missing, always use the enable uni-directional printing. default printing mode. CmdUniDirectionOff Quoted string, the command to disable uni-directional printing. CmdpushCursor Quoted string, the command to push Optional. the current cursor position onto the stack for later retrieval. CmdPopCursor Quoted string, the command to pop Optional. the last cursor position on the stack and restore it as the current cursor position. CmdBackSpace Quoted string, the command to Optional. This is used only for printing backspace a single character width. over-strike characters. The printer must be able to move the cursor back the width of the last printed character with this command.

40 General Printing: Color

Entry Name Description Comment *EnableGDIColorMapping? Boolean, shall GDI perform gamut Optional. If missing, assume FALSE. mapping from display to printer This keyword sets the colorspace? The printer colorspace is HT FLAG DO DEVCLR XFORM defined by the COLORINFO flag in GDINFO. structure and some GPD keywords. *ChangeOolorModeOnPage? Boolean, whether a color printer can Optional. If missing, assume FALSE, change the color mode (such as i.e. the driver cannot change the color monochrome vs. CMYK, or CMY printing mode within a page. This is vs. 24bpp) on a page without other used to optimize printing speed. side effects such as page ejection. *ChangeOolorModeOnDoc? Boolean, whether a color printer can Optional. If missing, assume TRUE. change the color mode from one page to another page within one document without other side effects. * MagentainCyanDye Integer (0-1000), ink impurity Optional. If missing, assume -1 to adjustment to specify magenta utilize internal defaults. Specify value contamination in cyan dye. as 100 * percent contamination (i.e. 8.4% as 840). *YellowInCyanDye Integer (0-1000), ink impurity Same as above. adjustment to specify yellow contamination in cyan dye. *CyanInMagentaDye Integer (0-1000), ink impurity Same as above. adjustment to specify cyan contamination in magenta dye. US 6,825,941 B1 101 102

-continued Entry Name Description Comment *YellowIn MagentalDye Integer (0-1000), ink impurity Same as above. adjustment to specify yellow contamination in magenta dye. *CyanInYellowDye Integer (0-1000), ink impurity Same as above. adjustment to specify cyan contamination in yellow dye. * MagentanYellowDye Integer (0-1000), ink impurity Same as above. adjustment to specify magenta contamination in yellow dye. CmdSelectBlackColor Quoted string, command to select Optional. This set of 8 primary color black color for the foreground. The selection commands are used by planar foreground color is used to print text color printers (such as dot-matrix and vector graphics (if available). printers) and palette color printers which does not support programmable color palettes (such as early inkjet printers). CmdSelectRedColor Quoted string, command to select red Same as above. color for the foreground. CmdSelectGreenColor Quoted string, command to select Same as above. green color for the foreground. CmdSelectYellowColor Quoted string, command to select Same as above. yellow color for the foreground. CmdSelectBlueColor Quoted string, command to select Same as above. blue color for the foreground. CmdSelectMagentaColor Quoted string, command to select Same as above. magenta color for the foreground. CmdSelectCyancolor Quoted string, command to select Same as above. cyan color for the foreground. CmdSelectWhiteColor Quoted string, command to select Same as above. white color for the foreground. CmdBeginPaletteDef Quoted string, the command to Optional. For palette printing modes, initialize color palette definition. if this entry is missing, it means there is no required initialization. This set of palette commands are used by color printers which supports programmable palettes that can be used for both the foreground (i.e. text and vector graphics) and raster printing. CmdEndPaletteDef Quoted string, the command to finish Optional. For palette printing modes, color palette definition. if it is missing, it means there is nothing to be done. CmdDefinePaletteEntry Quoted string, the command to define Optional, but required for palette a color palette entry. printing modes. CmdSelectPaletteEntry Quoted string, the command to select Optional, but required for palette a color palette entry as the current printing modes. color. CmdSelectBlackBrush Quoted string, the command to select Required. a solid black brush as the current brush. CmdSelectWhiteBrush Quoted string, the command to select Optional. For devices that supponts a solid white brush as the current white solid brush. brush. CmdDownloadPattern Quoted string, the command to Optional. If defined, CmdSelectPattern download a pattern brush to the must also be defined. device. CmdSelectPattern Quoted string, the command to select Optional. If defined, a downloaded pattern brush as the CmdDownloadPattern must also be current brush. defined.

General Printing:9. Overlay resources that can be downloaded once to the pprinter and 55 then referenced many times. Only one overlay pattern can be Some printerS Support overlays (a.k.a. watermarks) which Selected at the beginning of each page. Here are the should be treated like fonts in the sense that it is a type of attributes and commands associated with printing overlayS:

Entry Name Description Comment *MinOverlayID integer, minimum id for Optional. If missing, assume 1. downloading an Overlay pattern. *MaxOverlayID integer, maximum id for Optional. If missing, assume no limit. downloading an Overlay pattern. US 6,825,941 B1 103 104

-continued Entry Name Description Comment CmdOverlayRegStart quoted string, command for Optiona . If missing, assume no support starting the overlay registration. for overlays. Typically, it sets the overlay id. The overlay pattern data are downloaded next. CmdOverlayRegEnd quoted string, command for Optiona . If missing, assume no support ending the overlay registration. for overlays. This is sent right after the overlay pattern data. CmdEnableOverlay quoted string, command for Optiona . If missing, assume no support selecting a downloaded Overlay for overlays. pattern (typically via id). This command should be sent at the beginning of a page. CmdDisableOverlay quoted string, command for Optiona . If missing, assume no support disabling the use of any overlay, for overlays. This command should be sent at the beginning of a page.

Just like font installers, there should be an overlay man When CmdEnable OEMComp is specified, Unidrvis ager which provides the user interface to create, locate and expects the OEM DLL to provide the following callback install overlay pattern files. The driver would copy the function: content of this file after sending the command CmdSetOver 25 layID. DWORD OEMCompression( Raster Printing: Data Compression PBYTE pnBuf, //pointer to the input buffer containing the UnidrV5 assumes that the printer's raster data compres original raster data Sion mode can be turned on or off independently of other PBYTE p0utBuf, //pointer to the output buffer for the raster commands, Such as CmdSend BlockData. The current compressed data compression method is part of the printer's global State DWORD dwin Len, //the length of the input data to com information. It is also assumed that once a compression preSS method is Selected, it remains in effective until another DWORD dwOutLen, //the size of the output buffer (in bytes) method is Selected or the compression is disabled. ) UnidrV5 Supports a set of Standard raster data compres 35 sion algorithms. They preferably include TIFF4.0 and Delta The return value is the length of the compressed data in Row Compression (DRC) as defined in HP/PCL reference bytes. This function should return Zero if the output buffer is manual as well as Far East run length encoding (FERLE). not big enough to hold the compressed data. Typically, These methods as well as OEM supplied compression can be UnidrV5 would start with an output buffer the same size as intermixed on a per Scanline basis. The GPD allows OEM’s 40 the input buffer. If the return value is greater than the input to define custom compression algorithms via the OEMCom buffer size, Unidrvis would issue the command CmdDis pression callback. At most one custom compression method ableCompression and Send the uncompressed data. When can be specified per printer configuration. When a custom there are multiple compression methods specified (treating method is used, Unidrvis would utilize the OEMCompres no-compression as a special compression method), the most Sion callback to compress the raster data and then compare 45 compressed method is used on per Scanline/block basis. it against the compressed size of any other active compres On Some FE printers, the compression Selection is Sion mode and use the most efficient method. mingled with Sending data. In that case, only one compres

Entry Name Description Comments CmdEnableTIFF4 Quoted string, command to select Optional. If missing, Unidrv5 will not TIFF4.0 raster data compression. attempt TIFF4.0 compression. CmdEnableDRC Quoted string, command to select Optional. If missing, Unidrv5 will not delta-row raster data compression. attempt DRC. If both TIFF4 and DRC commands are listed, Unidrv5 will choose the optimal compression on per scanline basis. CmdEnableFE RLE Quoted string, command to select FE Optional. If missing, Unidrv5 will not RLE raster data compression. use FE-RLE compression. CmdEnableOEMComp Quoted string, command to select an Optional. Note that it does not make OEM defined raster data compression sense for this command to co-exist with algorithm. the standard TIFF4 or DRC command for any printer configuration. CmdDisableCompression Quoted string, command to disable any Optional. raster data compression, including both standard and custom methods. US 6,825,941 B1 105 106 Sion method can be used. The compression Selection should should be no *CmdDisableCompression entry because there be hardcoded in CmdSend BlockData or other similar data is no way to turn off compression. emission commands. The corresponding compression Selec tion command should be an empty quoted String. There Raster Printing: Raster Data Emission

Entry Name Description Comments *OutputDataFormat Constant(H. BYTE or V BYTE), the Optional. If missing, assume output data direction, i.e. whether the H BYTE. For example, all page bits in a data byte are mapped to printers use H BYTE format. horizontal pixels or vertical pixels. *OptimizeLeftBound? Boolean, whether to remove blanks at Optional. If missing, assume no the left bound of a band. optimization. *StripBlanks LIST(LEADING, ENCLOSED, Optional. If missing, assume empty TRAILING), the ways to strip blanks list, i.e. no blank stripping. Note in a raster data block. that if any compression (such as TIFF4) is specified, it's usually more efficient not to request stripping enclosed blanks. *RasterSendAIData? Boolean, whether the driver should Optional. If missing, Unidrv5 send all color plane raster data assumes FALSE. regardless of blank scanlines or blanks within a scanline. * Mirror RasterByte? Boolean, whether the driver mirrors a Optional. If missing, Unidrv5 raster image per 8 bits. assumes FALSE. CursorXAfterSendElockData Constant (AT GRXDATA END, Optional. If missing, assume AT GRXDATA ORIGIN, or AT GRXDATA END, i.e. the AT CURSOR X ORIGIN), the cursor X moves to the pixel after the cursor X position after sending a block last pixel of the graphics block. of raster graphics data. CursorYAfterSendElockData Constant (NO MOVE, optional. If missing, assume AUTO INCREMENT), the cursor Y NO MOVE, i.e. the cursor Y stays position after sending a block of raster at the original position. data. *UseExpColorSelectCmd? Boolean, whether color selection Optional. If missing, assume commands are separate from the FALSE. For all dot-matrix printers, commands to send color raster data. this field is TRUE. *MoveToXOBeforeSetColor? Boolean, whether moving to the Optional. If missing, assume physical X=0 before sending the FALSE. This field makes sense only explicit color selection command. if*UseExpColorSelectCmd? is TRUE. CmdBeginRaster Quoted string, the command to optional. If missing, it implies that initialize raster data transfer. no initialization is needed. CmdEndRaster Quoted string, the command to finish optional. If missing, it means there is raster data transfer. It is used in pairs nothing to be done when raster data with CmdBeginRaster transfer is completed. CmdSetDestBmpWidth Quoted string, command to set the Applicable only to printers which can destination bitmap width. scale raster graphics. CmdSetDestBmpHeight Quoted string, command to set the Same as above. destination bitmap height. CmdSetSrcBmpWidth Quoted string, command to set the Same as above. source bitmap width CmdSetSrcBmpHeight Quoted string, command to set the Same as above. source bitmap height. CmdSendElockData Quoted string, the command to send Required unless the printer type is one block of data to the printer. One TTY (text only). block of data fills one physical pass of the print head. For V BYTE type printers, one block has *PinsPerPhysPass number of scanlines. For H. BYTE type printers, one block has *PinsPerLogPass number of scanlines. CmdEndBlockData Quoted string, the command to end Optional. If missing, assume NULL. sending one block of data to the printer. This command is sent after the raster data. This is used on some dot matrix printers. *SendMultipleRows? Boolean, whether CmdSendBlockData Optional. If missing, assume can send multiple blocks in one shot. FALSE. This is used only by H. BYTE type printers. CmdSendRedData Quoted string, the command to send Required if planar color printing is red plane data. used. CmdSendGreenData Quoted string, the command to send Same as above. green plane data. CmdSendElueData Quoted string, the command to send Same as above. blue plane data. US 6,825,941 B1 107 108

-continued Entry Name Description Comments CmdSendCyan Data Quoted string, the command to send Same as above. cyan plane data. CmdSendMagentaData Quoted string, the command to send Same as above. magenta plane data. CmdSend YellowData Quoted string, the command to send Same as above. yellow plane data. CmdSendElackData Quoted string, the command to send Same as above. black plane data.

Text Printing: Device Fonts

Entry Name Description Comments *DefaultFont Integer, the Windows RC FONT Required, if the printer supports any resource id of the default font. device fonts. * MaxFontUsePerPage Integer, the limit on the number of fonts Optional. If missing, assume no limit. (resident or downloaded) that the printer can use on a page. *DefaultCTT Integer, the Windows RC CTT resource Optional. If missing, assume 0, i.e. no id of the default character translation translation. table. This entry is provided only for backward compatibility with GPC. * LookaAhead Region Integer, the number of pixels (in master Optional. If missing, assume 0. Y unit) that the driver needs to look ahead when determining whether it should emit text. This is applicable only to serial printers, inkjet printers in particular. *TextYOffset Integer, the Y distance (in master Y Optional. If missing, assume 0. unit) by which to reposition printer resident fonts in order to align correctly with baselines of bitmap fonts. This is used on some dot-matrix printers. *CharPosition Constant (UPPERLEFT, BASELINE), Optional. If missing, assume where the print head should be UPPERLEFT, i.e. Unidrv5 would positioned before printing a character. position the print head at the upper left corner of the character bounding box before printing it.

Text Printing: Font Downloading

Entry Name Description Comments *MnFont)

-continued

Entry Name Description Comments CmdSelectFont) Quoted string, the command to select a Optional. If missing, assume that there is font id, i.e. make that font active. no font downloading support on the printer. CmdSetCharCode Quoted string, the command to set the Same as above CmdSetFontLD, current character code whose data will CmdSelectFont) and CmdSetCharCode be sent immediately after. are bounded as a group, i.e. they must all exist or none at all. CmdSelectFontHeight Quoted string, the command to select Optional, If missing assume that printer font height. does not support scaleable, downloadable TrueType outline fonts. This command is needed for HPPCL OUTLINE format. CmdSelectFontWidth Quoted string, the command to select Optional, If missing assume that width of font Width. downloaded font is scaled proportionally to the font height. FontFormat Constant (HPPCL, HPPCL RES, Required if the printer supports font HPPCL OUTLINE, downloading. If OEM CALLBACK is OEM CALLBACK), the font specified, the corresponding callback downloading format. functions must be provided in the OEM extension dll. CmdDeletePont Quoted string, the command to delete Optional. If this entry is specified, a temporary soft font by id. Unidrv5 assumes that when a font is deleted, its memory can be reclaimed immediately. Otherwise, this entry should not be defined.

Font Printing: Font Simulation

Entry Name Description Comments CmdSetFontSim Quoted string, the command to Set Optional. If present, Unidrv5 assumes italic?bold/underline/strike-through that the printer cannot remember any simulation in one shot. attribute state information and must be set each time a font is used. CmdClear AIFontattribs Quoted string, one command that will If the printer supports Bold, Italic or set all Bold, Italic and Underline Underlining, but does not support the attributes OFF commands to turn individual attributes off, this command may be defined in place of the individual commands CmdBoldOff, CmdItalicOff, CmdUnderlineOff. CmdBoldOn Quoted string, the command to set bold Optional. If present, Unidrvs assumes attribute ON. that the printer can set bold attribute independently and that once it is set, it remains effective until the opposite command (i.e. CmdBoldOff) is sent to change the state. CmdBoldOff Quoted string, the command to set bold Optional, but it must be paired with attribute OFF. CmdBoldOn command. CmdtalicOn Quoted string, the command to set Similar to CmdBoldOn. italic attribute ON. CmdtalicOff Quoted string, the command to set Similar to CmdEoldOff. italic attribute OFF. CmdnderlineOn Quoted string, the command to set Similar to CmdBoldOn. underline attribute ON. CmdUnderlineOff Quoted string, the command to set Similar to CmdEoldOff. underline attribute OFF. CmdStrikeThruOn Quoted string, the command to set Similar to CmdBoldOn. strike-through attribute ON. CmdStrikeThruOff Quoted string, the command to set Similar to CmdEoldOff. strike-through attribute OFF. CmdWhiteTextOn Quoted string, the command to enable Optional. This is for backward white text printing. compatibility with GPC 3.0. CmdWhiteTextOff Quoted string, the command to disable Optional, but it must be paired with white text printing. CmdWhiteTextOff. CmdSelectSingleByte Mode Quoted string, the command to select Optional. If missing, assume there is single-byte printing mode. This is used no mode switching for text printing. on FE printers. CmdSelectDoubleByte Mode Quoted string, the command to select Optional, but it must be paired with double-byte printing mode. This is CmdSelectSingleByte Mode. used on FE printers. US 6,825,941 B1 111 112

-continued Entry Name Description Comments *DiffFontsPerByte Mode? Boolean, whether the single-byte mode Optional. If missing, assume FALSE. and the double-byte mode maintain separate states regarding the current font and current font simulation attributes. CmdVertical PrintingOn Quoted string, the command to enable Optional. If missing, assume that the vertical printing mode. This is used on vertical printing is not supported on FE printers. the printer. CmdVertical PrintingOff Quoted string, the command to disable Optional, but it must be paired with vertical printing mode. This is used on CmdVertical PrintingOff. FE printers CmdBoldOff Quoted string, the command to set bold Optional, but it must be paired with attribute OFF. CmdBoldOn command. CmdtalicOn Quoted string, the command to set Similar to CmdBoldOn. italic attribute ON. CmdtalicOff Quoted string, the command to set Similar to CmdEoldOff. italic attribute OFF. CmdnderlineOn Quoted string, the command to set Similar to CmdBoldOn. underline attribute ON. CmdUnderlineOff Quoted string, the command to set Similar to CmdEoldOff. underline attribute OFF. CmdStrikeThruOn Quoted string, the command to set Similar to CmdBoldOn. strike-through attribute ON. CmdStrikeThruOff Quoted string, the command to set Similar to CmdEoldOff. strike-through attribute OFF. CmdWhiteTextOn Quoted string, the command to enable Optional. This is for backward white text printing. compatibility with GPC 3.0 CmdWhiteTextOff Quoted string, the command to disable Optional, but it must be paired with white text printing. CmdWhiteTextOff. CmdSelectSingleByte Mode Quoted string, the command to select Optional. If missing, assume there is single-byte printing mode. This is used no mode switching for text printing. on FE printers. CmdSelectDoubleByte Mode Quoted string, the command to select Optional, but it must be paired with double-byte printing mode. This is CmdSelectSingleByte Mode. used on FE printers. *DiffFontsPerByte Mode? Boolean, whether the single-byte mode Optional. If missing, assume FALSE. and the double-byte mode maintain separate states regarding the current font and current font simulation attributes. CmdVertical PrintingOn Quoted string, the command to enable Optional. If missing, assume that the vertical printing mode. This is used on vertical printing is not supported on FE printers. the printer. CmdVertical PrintingOff Quoted string, the command to disable Optional, but it must be paired with vertical printing mode. This is used on Cmdvertical PrintingOff. FE printers.

Numerous modifications and alternative embodiments of cific device driver functions invoked by the graphic the invention will be apparent to those skilled in the art in 45 device interface, the text based minidriver including View of the foregoing description. Accordingly, this descrip- means for outputting the text based characterization; tion is to be construed as illustrative only and is for the and - purpose of teaching those skilled in the art the best mode for a modular universal driver which incorporates the text carrying out the invention. Details of the Structure and 50 R.E.R.E. Sveins: based implementation of the various components described above the devices Specific driver functions to controlplementing the can be varied Substantially without departing from the Spirit outputting of data to the output device in accordance of the invention, and exclusive use of all modifications that with the incorporated text based characterization. come within the Scope of the appended claims is reserved. 2. The computer System of claim 1, wherein the modular What is claimed is: ss universal driver provides a standard user interface for user 1. A computer System for Outputting data to an output Selection and control of device Specific driver functions, device, comprising: wherein the text based minidriver provides output device an application program for invoking a plurality of graph Specific user interface information relating to device Specific ics device interface functions to control the Sending of device driver functions, and wherein the universal driver data to the output device; incorporates the output device Specific user interface infor 60 mation in the Standard user interface provided thereby. a graphics device interface for invoking a plurality of 3. The computer system of claim 1, wherein the output device driver functions for controlling the outputting of device Specific user interface information contains informa data in response to the invocation of the plurality of tion for generating a separate user interface page, and graphics device interface functions, wherein the universal driver adds the Separate user interface a text based minidriver containing a text based charac 65 page to the Standard user interface provided thereby. terization of the output device, the text based charac 4. The computer system of claim 1, wherein the modular terization containing an implementation of device Spe universal driver provides a Standard user interface for user US 6,825,941 B1 113 114 Selection and control of device Specific driver functions, and characterization containing an implementation of wherein the text based minidriver provides output device device Specific device driver functions invoked by a Specific user interface information relating to device Specific graphic device interface; and device driver functions, and wherein the universal driver a unidriver rendering module for implementing the device replaces the Standard user interface with a device Specific user interface generated from the output device Specific user Specific driver functions to control the outputting of interface information. data to the output device in accordance with the text 5. A computer System for Outputting data to an output based characterization. device, comprising: 12. The computer-readable medium of claim 11, wherein an application program for invoking a plurality of graph the minidriver rendering module contains data for imple ics device interface functions to control the Sending of menting certain device Specific driver functions to control data to the output device; the outputting of data to the output device, and wherein the a graphics device interface for invoking a plurality of unidriver rendering module allows the minidriver rendering device driver functions for controlling the outputting of module to control the outputting of data to the output device data in response to the invocation of the plurality of for the certain device Specific driver functions. 15 13. The computer-readable medium of claim 11, wherein graphics device interface functions, the minidriver rendering module contains data for imple a text based minidriver containing a text based charac menting certain device Specific driver functions to control terization of the output device, the text based charac the outputting of data to the output device, and wherein the terization containing an implementation of device Spe unidriver rendering module incorporates the data from the cific device driver functions invoked by the graphic minidriver rendering module to modify the implementation device interface, the text based minidriver including of certain device Specific driver functions to control the means for outputting the text based characterization; outputting of data to the output device. a modular universal driver which incorporates the text 14. The computer-readable medium of claim 11, wherein based characterization passed by the text based the minidriver rendering module contains data for imple minidriver, the modular universal driver implementing 25 menting device Specific driver functions to control the the device Specific driver functions to control the outputting of data to the output device, and wherein the outputting of data to the output device in accordance unidriver rendering module incorporates the function ren with the incorporated text based characterization; and dering module to replace the implementation of the device wherein the text based minidriver contains at least one Specific driver functions provided by the unidriver rendering installable device Specific device driver function, and module to control the outputting of data to the output device. wherein the text based minidriver provides output 15. The computer-readable medium of claim 11, further device specific user interface information relating to comprising: installed device Specific device driver functions, and a minidriver user interface module for providing output wherein the universal driver utilizes the information device Specific user interface information relating to relating to installed device Specific device driver func 35 tions to display only installed device Specific device device Specific device driver functions, and driver functions on the user interface. a unidriver user interface module for providing a Standard 6. The computer system of claim 1, wherein the text based user interface for user Selection and control of device minidriver further includes at least one function rendering Specific driver functions, the unidriver user interface module for implementing certain device Specific driver 40 module incorporating the output device Specific user functions to control the outputting of data to the output interface information in the Standard user interface device, and wherein the modular universal driver allows the provided thereby. function rendering module to control the outputting of data 16. The computer-readable medium of claim 15, wherein to the output device for the certain device Specific driver the output device Specific user interface information con functions. 45 tains information for generating a separate user interface 7. The computer system of claim 1, wherein the text based page, and wherein the unidriver user interface module adds minidriver further includes at least one function rendering the Separate user interface page to the Standard user interface module, and wherein the modular universal driver incorpo provided thereby. 17. The computer-readable medium of claim 11, further rates the function rendering module to modify the imple comprising: mentation of certain device Specific driver functions to 50 control the outputting of data to the output device. a minidriver user interface module for providing output 8. The computer system of claim 1, wherein the text based device Specific user interface information relating to minidriver further includes a function rendering module, and device Specific device driver functions, and wherein the modular universal driver incorporates the func a unidriver user interface module for providing a Standard tion rendering module to replace the implementation of the 55 user interface for user Selection and control of device device specific driver functions provided by the universal Specific driver functions, the unidriver user interface driver to control the outputting of data to the output device. module replacing the Standard user interface with the 9. The computer system of claim 1, wherein the text based output device Specific user interface information pro characterization includes dependencies between certain vided by the minidriver user interface module. device Specific device driver functions. 60 18. A method of characterizing a printer device to allow 10. The computer system of claim 1, wherein the text its inclusion in a computer System having an application based characterization includes constraints on certain device program which invokes graphic device interface functions to Specific device driver functions. control the outputting of printable data, and an universal 11. A computer-readable medium having computer driver for implementing device Specific functions based on executable modules comprising: 65 characterization information for the particular printer a minidriver rendering module containing a text based device, the device Specific functions controlling the output characterization of an output device, the text based ting of data in accordance with the characterization infor US 6,825,941 B1 115 116 mation to allow proper printing and control of the printer System having an application program which invokes device, the method comprising the Steps of: graphic device interface functions to control the outputting opening a text editor; of printable data, and an universal driver for implementing creating a text based minidriver using the text editor, the device Specific functions based on characterization informa text based minidriver containing a text based charac tion for the particular printer device provided by the terization of the printer device, the text based charac minidriver, the device Specific functions controlling the terization containing an implementation of printer outputting of data in accordance with the characterization device specific device driver functions invoked by the information to allow proper printing and control of the graphic device interface, the text based minidriver printer device, the method comprising the Steps of: including means for outputting the text based charac terization to the universal driver, and opening the minidriver in a text editor; installing the text based minidriver. modifying the minidriver; 19. The method of claim 18, wherein the step of creating Saving the minidriver in the text editor; and a text based minidriver comprises the Steps of: 15 installing the minidriver. creating a text based rendering module including imple 21. The method of claim 20, wherein the step of modi mentations of printer device Specific device driver fying the minidriver comprises the Step of adding a new functions, and feature to the printer characterization. creating a text based user interface module including 22. The method of claim 20, wherein the step of modi output device Specific user interface information relat fying the minidriver comprises the Step of Specifying a ing to printer device Specific device driver functions. dependency between printer Settings. 20. A method of modifying a printer minidriver charac terizing a printer device to allow its inclusion in a computer