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 bidirectional 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:
- If the print job destination is a file, the spooler part of the printer system is not involved in fulfilling the direct print request. See steps 2, 3, and 4 of the scenario, which are dedicated to printing directly to a file specified by the application that initiated the print request.
- In this example scenario, which starts with the application initiating a print job when the "Print directly to printer" option is set for the application-specified printer, if the print job destination is not a file, then the determination of whether the print request is a direct request is made by the local print provider StartDoc function (inside the spooler). That determination is based on the current setting of the printer specified in the print request, not on an attribute set in the print request itself. A print job is "direct" because the printer it is destined for is set to "Print directly to printer" when the print job is initiated (when the printing application executes a StartDoc function).
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.
- 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 file name if the application wants to print directly to a file.
- If the GDI StartDoc function determines that there is an output file name 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.
- In the case of printing directly to a file, the 16-bit printer driver returns the rendered circle to 16-bit GDI.
- 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.
- If the GDI StartDoc function finds no output file name 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).
- GDI32 makes an interprocess call to the spooler process.
- SPOOL32.EXE calls the router to route the print job to the printer specified by the application.
- 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.
- When success is returned from the local print provider, the application makes the call to render the circle.
- GDI calls the printer driver associated with the specified printer to render the circle.
- The 16-bit printer driver returns the rendered circle to 16-bit GDI.
- GDI passes the print request to 32-bit GDI.
- GDI32 makes an interprocess call to the spooler process.
- SPOOL32.EXE calls the router to route the print job to the printer specified by the application.
- 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.
- The local print provider sends the print request to the language monitor associated with the requested printer (note that in this example, a bidirectional 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.
- The language monitor calls the port monitor to send data to the printer.
- 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.