ADC Home > Reference Library > Technical Q&As > Legacy Documents > Printing >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

QuickDraw GX Printing Extensions

Important for all Apple Printing and Graphics Developers:

The information in this Technical Q & A is still relevant up to and including Mac OS 7.6 with QuickDraw GX 1.1.5. Beginning with the release of Mac OS 8.0, however, Apple plans to deliver a system which incorporates QuickDraw GX graphics and typography only. QuickDraw GX printer drivers and GX printing extensions will not be supported in Mac OS 8.0 or in future Mac OS releases. Apple's goal is to simplify the user experience of printing by unifying the Macintosh graphic and printing architectures and standardizing on the classic Printing Manager.

For details on Apple's official announcement, refer to </dev/technotes/gxchange.html>

Q: I needed to add some PostScript comments to the beginning of the PostScript files generated by the LaserWriter GX driver. I wrote a GX printing extension to accomplish this, assuming that all I had to do was to override the GXPostScriptDoDocumentHeader message and buffer the desired data using Send_GXBufferData. Here is an example of my code:

OSErr NewPostScriptDoDocumentHeader(gxPostScriptImageDataHdl hImageData) {
   OSErr   theStatus=noErr;

   strcpy(dataBuffer, "%%DAVE'S TEST DATA");
   bufferLen = strlen(dataBuffer);
   theStatus = Send_GXBufferData((Ptr) dataBuffer, bufferLen,gxNoBufferOptions)
   if (theStatus != noErr)

   theStatus = Forward_GXPostScriptDoDocumentHeader(hImageData);

} // NewPostScriptDoDocumentHeader

Unfortunately,this causes a bus error when Send_GXBufferData is called, even if I put Send_GXBufferData after the call to Forward_GXPostScriptDoDocumentHeader. My workaround for this problem was to buffer the data from within an override of GXOpenConnection.

On page 4-119 of the QuickDraw GX documentation (Inside Macintosh: QuickDraw GX Printing Extensions and Drivers), it says, You can override this message [GXPostScriptDoDocumentHeader] to build your own document header or to add comments to a PostScript header. Why doesn't this work?

A: The override in your extension is basically correct, but the order of your code needs to be slightly different:

// note that the string is terminated with a <cr>
#define kTestStr "%% Dave's test data\n"

OSErr NewPostScriptDoDocumentHeader(gxPostScriptImageDataHdl hImageData) {
   OSErr   theStatus=noErr ;
   char    dataBuffer[256] ;
   long    bufferLen ;

   theStatus = Forward_GXPostScriptDoDocumentHeader(hImageData);
   if (theStatus != noErr)

   // Note that we do (sizeof(...) -1) below to strip off
   // the C string null terminator for the string defined
   theStatus = Send_GXBufferData( kTestStr,
                                 (sizeof( kTestStr) - 1,
                                 0) ;


} // NewPostScriptDoDocumentHeader

Make sure that the string is terminated with a carriage return. If you're using a #define to allocate static space for the string (this is not recommended), remember that it allocates the string, plus a null terminator. Sizeof then returns the size of the string, so you need to subtract 1 from the total. This string should come from a resource or a data/prefs file.

If you want to add to the header from an application (to avoid writing the extension), you can add an item to the job collection of type 'post', using the tag gxPrintingTagID. If the first character of this item is a '%' character, it will appear in the job header.

[May 01 1995]

Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.