Important: The information in this document is obsolete and should not be used for new development.
Synchronizing QuickDraw and PostScript Printer Drivers
QuickDraw instructions such as those generated by theMove,MoveTo,PenPat, andPenSizeroutines change the state of the current graphics port without going through the standard low-level routines pointed to in theQDProcsrecord for the current graphics port. A printer driver takes these changes into account only at the time it executes an actual drawing instruction. The printer driver uses the routines specified in theQDProcsrecord at execution time and responds only to those instructions handled by the routines in theQDProcsrecord. Therefore, you should flush the state of the printing graphics port explicitly by calling any routine that goes through theQDProcs.lineProcfield, as shown in Listing B-1, before inserting code using picture comments for a PostScript driver. The use of the application-defined routineMyFlushGrafPortStateshown here is further illustrated in Listing B-8 on page B-33.Listing B-1 Synchronizing QuickDraw and the PostScript driver
PROCEDURE MyFlushGrafPortState; VAR penInfo: PenState; BEGIN GetPenState(penInfo); {save pen size} PenSize(0,0); {make it invisible} MoveTo(-3200,-3200); {move the pen way off the page in } { case the printer driver draws a dot } { even with a pen size of (0,0)} Line(0,0); {go through QDProcs.lineProc} {next, restore pen size} PenSize(penInfo.pnSize.h, penInfo.pnSize.v); END;A PostScript printer driver separates the PostScript code generated for text-drawing instructions (which usually involves font queries and, sometimes, font downloading) from the picture comments intended for PostScript devices. In certain cases, this results in apparently nonsequential execution of drawing instructions and may affect clipping regions or have side effects on the drawing operations you include in picture comments. To synchronize the sequence of QuickDraw routines with the generation of PostScript code, you need to flush the buffer maintained by the PostScript driver. You can do this by using thePostScriptBeginpicture comment followed immediately by thePostScriptEndpicture comment. This causes all PostScript code, generated either by the application or by the printer driver, to be sent to the printer. Listing B-2 shows an application-defined procedure that does this. The use of the application-defined routineMyFlushPostScriptStateshown here is further illustrated in Listing B-4 on page B-23.Listing B-2 Flushing the buffer for a PostScript printer driver
PROCEDURE MyFlushPostScriptState; BEGIN PicComment(PostScriptBegin, 0, NIL); PicComment(PostScriptEnd, 0, NIL); END;