<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGContext/init(consumer:mediaBox:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core Graphics",
      "CoreGraphics"
    ],
    "preciseIdentifier" : "c:@F@CGPDFContextCreate"
  },
  "title" : "init(consumer:mediaBox:_:)"
}
-->

# init(consumer:mediaBox:_:)

Creates a PDF graphics context.

```
init?(consumer: CGDataConsumer, mediaBox: UnsafePointer<CGRect>?, _ auxiliaryInfo: CFDictionary?)
```

## Parameters

`consumer`

The data consumer to receive the PDF output data.

`mediaBox`

A pointer to a rectangle that defines the size and location of the PDF page, or `NULL`. The origin of the rectangle should typically be `(0,0)`. Core Graphics uses this rectangle as the default bounds of the page’s media box. If you pass `NULL`, Core Graphics uses a default page size of 8.5 by 11 inches (612 by 792 points).

`auxiliaryInfo`

A dictionary that specifies any additional information to be used by the PDF context when generating the PDF file, or `NULL`. The dictionary is retained by the new context, so on return you may safely release it. See [Auxiliary Dictionary Keys](/documentation/CoreGraphics/auxiliary-dictionary-keys) for keys you can include in the dictionary.

## Return Value

A new PDF context, or `NULL` if the context cannot be created. In Objective-C, you’re responsible for releasing this object using [`CGContextRelease`](/documentation/CoreGraphics/CGContextRelease).

## Discussion

This function creates a PDF drawing environment to your specifications. When you draw into the new context, Core Graphics renders your drawing as a sequence of PDF drawing commands that are passed to the data consumer object.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)