Typical Direct Printing Process Scenario

This section illustrates the major relationships between the print spooler components, the printer driver, and GDI during the direct printing process -- when no spooling takes place. This scenario illustrates what happens when a direct printing job is carried out because the user has employed Details tab on the Printer Properties property sheet to set the Spool Settings to "Print directly to printer."

The presented scenario walks through the sequence of calls between printer system components between the time a direct print job is started by an application and the job's delivery to a bi-directional printer. Note that the application may not be aware of the fact that this is a direct print job, because the application does not know whether the user has set the "Print directly to printer" option or not.

The following illustration shows the sequence of calls and events that start with the application initiating a print job when the "Print directly to printer" option is set for the printer specified by the application to do the printing. This step is labeled 1 in the following illustration and the final step, where the print job is sent through the hardware port to the printer is labeled step 18. The direct print option of printing to a file instead of a printer is also shown in the illustration.

Important points to notice in this scenario are:

Each of the following paragraphs describes one of the calls between printer system components during the process of direct printing, either to a file or to a printer.

1 The application has a graphics object, for example a circle, to send to a printer. The application creates a DC and calls the GDI StartDoc function to initiate a print request for the printer. This request may also contain a filename if the application wants to print directly to a file.

2 If the GDI StartDoc function determines that there is an output filename in the print request, then GDI returns success to the application and the application makes the call to draw the circle. GDI calls the printer driver associated with the specified printer to render the circle.

3 In the case of printing directly to a file, the 16-bit printer driver returns the rendered circle to 16-bit GDI.

4 Continuing with the case of printing directly to a file, GDI writes the rendered circle to the output file specified in the print request. GDI is the appropriate printer system component to write results of the direct print job to a file because it has the same current directory as the application, and the current directory information may be needed to generate a full path to the destination file. The printer subsystem (the spooler) does not know the application's current directory. So, in the case of a direct print job to a file, the 32-bit side of the printer system is not involved at all.

5 If the GDI StartDoc function finds no output filename in the print request, then the destination must be the printer. GDI passes the print request to 32-bit GDI instead of returning to the application (and steps 3 and 4 of the scenario are skipped).

6 GDI32 makes an interprocess call to the spooler process.

7 SPOOL32.EXE calls the router to route the print job to the printer specified by the application.

8 The router calls the local print provider with the print job request. The StartDocPrinter function within the local print provider checks whether the current configuration of the printer is "Print directly to printer." If the printer specified in the print request is currently set to "Print directly to printer," then the local print provider checks to see if the port associated with the requested printer is busy or not. If the port is busy with another print job on any printer attached to that port, for example despooling a previously spooled print job, then the local print provider returns an error condition to the application. If the port is not busy, the local print provider reserves the port exclusively for the direct print job and returns success to the application.

9 When success is returned from the local print provider, the application makes the call to render the circle.

10 GDI calls the printer driver associated with the specified printer to render the circle.

11 The 16-bit printer driver returns the rendered circle to 16-bit GDI.

12 GDI passes the print request to 32-bit GDI.

13 GDI32 makes an interprocess call to the spooler process.

14 SPOOL32.EXE calls the router to route the print job to the printer specified by the application.

15 The router calls the local print provider WritePrinter function with the print job request. The local print provider recognizes the job as a direct print job for which it has reserved a port.

16 The local print provider sends the print request to the language monitor associated with the requested printer (note that in this example, a bi-directional printer is being used). Note that the local print provider dedicates the use of the port to outputting the direct print job until the job is ended.

17 The language monitor calls the port monitor to send data to the printer.

18 The port monitor sends data through the physical port to the connected printer. Steps 10 through 18 are repeated until all the print job data is printed or the print job is canceled.