Contents

PMSessionGetGraphicsContext

Obtains the graphics context for the current page in a printing session.

Declaration

OSStatus PMSessionGetGraphicsContext (
   PMPrintSession printSession,
   CFStringRef graphicsContextType,
   void **graphicsContext
);

Parameters

  • printSession:

    The printing session whose current graphics context you want to obtain.

  • graphicsType:

    The desired graphics context type. This parameter is currently ignored.

  • graphicsContext:

    On return, a reference to the current graphics context. The graphics context returned is the one last set by a call to the function PMSessionSetDocumentFormatGeneration or the default (QuickDraw) if there was no call to the function. You must typecast the context to an appropriate graphics type, either grafPtr or Cgcontext.

Return Value

A result code. See Result Codes.

Overview

You must call this function between the creation and release of a printing session. See the function PMCreateSession. You must also call the function PMSessionGetGraphicsContext within the scope of the functions PMSessionBeginPage and PMSessionEndPage.

In OS X v10.3 and earlier, you should call this function for each page you draw for a print job. After each call to the function PMSessionBeginPage your application should call PMSessionGetGraphicsContext to obtain the current graphics context. If that context is a QuickDraw context, then set the drawing port to this port by calling the QuickDraw SetPort function. See the discussion of the function PMSessionBeginPage for more information.

Special Considerations

In macOS 10.4 and later, Apple recommends using the function PMSessionGetCGGraphicsContext instead of this function. QuickDraw is deprecated and your application should be using Quartz 2D for its rendering.

See Also

Accessing Data in Printing Session Objects