---
title: PMSessionGetGraphicsContext
framework: Application Services
role: pseudoSymbol
platforms: []
path: applicationservices/core_printing/1805529-pmsessiongetgraphicscontext
---

# PMSessionGetGraphicsContext

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

## Declaration

```occ
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 [doc://com.apple.coregraphics/documentation/CoreGraphics/CGContext](coregraphics/cgcontext.md).

## Return Value

A result code. See [Result Codes](../core_printing.md).

## Overview

You must call this function between the creation and release of a printing session. See the function [PMCreateSession](../1463247-pmcreatesession.md). 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](../1461952-pmsessiongetcggraphicscontext.md) 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

- [PMSessionGetDataFromSession](../1462964-pmsessiongetdatafromsession.md)
- [PMSessionSetDataInSession](../1461902-pmsessionsetdatainsession.md)
- [PMSessionGetCurrentPrinter](../1458998-pmsessiongetcurrentprinter.md)
- [PMSessionSetCurrentPrinter](1805523-pmsessionsetcurrentprinter.md)
- [PMSessionSetCurrentPMPrinter](../1461096-pmsessionsetcurrentpmprinter.md)
- [PMSessionGetDocumentFormatGeneration](1805525-pmsessiongetdocumentformatgenera.md)
- [PMSessionSetDocumentFormatGeneration](1805527-pmsessionsetdocumentformatgenera.md)
- [PMSessionGetCGGraphicsContext](../1461952-pmsessiongetcggraphicscontext.md)
- [PMSessionError](../1460003-pmsessionerror.md)
- [PMSessionSetError](../1460216-pmsessionseterror.md)
- [PMSessionGeneral](1805530-pmsessiongeneral.md)
