<!--
{
  "availability" : [
    "macOS: 10.0.0 - 12.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "QuickLook",
  "identifier" : "/documentation/QuickLook/QLPreviewRequestCreatePDFContext(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Quick Look"
    ],
    "preciseIdentifier" : "c:@F@QLPreviewRequestCreatePDFContext"
  },
  "title" : "QLPreviewRequestCreatePDFContext(_:_:_:_:)"
}
-->

# QLPreviewRequestCreatePDFContext(_:_:_:_:)

Creates a PDF context suitable to draw a multi-page preview.

```
func QLPreviewRequestCreatePDFContext(_ preview: QLPreviewRequest!, _ mediaBox: UnsafePointer<CGRect>!, _ auxiliaryInfo: CFDictionary!, _ properties: CFDictionary!) -> Unmanaged<CGContext>!
```

## Parameters

`preview`

The preview request object.

`mediaBox`

A pointer to the media box of the context.

    A media box is a rectangle that defines the size and location of the PDF page. The origin of the rectangle should typically be (0,0). If you pass NULL, Quartz uses a default page size of 8.5 by 11 inches (612 by 792 points). For information see the description for     <doc://com.apple.documentation/documentation/CoreGraphics/CGContext/init(consumer:mediaBox:_:)>    .

`auxiliaryInfo`

A dictionary containing PDF auxiliary information. See the description of the auxiliary dictionary keys in <doc://com.apple.documentation/documentation/CoreGraphics/auxiliary-dictionary-keys> for more information about the keys and values of this dictionary.

`properties`

A dictionary containing additional properties for the preview response. For information on acceptable keys and values, see `Preview Properties`.

## Return Value

A reference to a Core Graphics context object that is used to display a PDF version of the preview. You should explicitly release this object when it is no longer needed.

## Discussion

Be sure to bracket each PDF page written to the context with <doc://com.apple.documentation/documentation/CoreGraphics/CGContext/beginPDFPage(_:)> and <doc://com.apple.documentation/documentation/CoreGraphics/CGContext/endPDFPage()> calls. After calling this function, you should flush the context with [`QLPreviewRequestFlushContext(_:_:)`](/documentation/QuickLook/QLPreviewRequestFlushContext(_:_:)).

### Special Considerations

Thread-safety: This function should be called in the same thread as the preview request is made in; generally, this is the same thread in which the `GeneratePreviewForURL` callback was invoked.

---

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)