Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Imaging With QuickDraw /
Appendix B - Using Picture Comments for Printing


Synchronizing QuickDraw and PostScript Printer Drivers

QuickDraw instructions such as those generated by the Move, MoveTo, PenPat, and PenSize routines change the state of the current graphics port without going through the standard low-level routines pointed to in the QDProcs record 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 the QDProcs record at execution time and responds only to those instructions handled by the routines in the QDProcs record. Therefore, you should flush the state of the printing graphics port explicitly by calling any routine that goes through the QDProcs.lineProc field, as shown in Listing B-1, before inserting code using picture comments for a PostScript driver. The use of the application-defined routine MyFlushGrafPortState shown 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 the PostScriptBegin picture comment followed immediately by the PostScriptEnd picture 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 routine MyFlushPostScriptState shown 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;

Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996