---
title: "QLPreviewRequestCreatePDFContext(_:_:_:_:)"
framework: quicklook
role: symbol
role_heading: Function
path: "quicklook/qlpreviewrequestcreatepdfcontext(_:_:_:_:)"
---

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

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

## Declaration

```swift
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

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

Discussion Be sure to bracket each PDF page written to the context with beginPDFPage(_:) and endPDFPage() calls. After calling this function, you should flush the context with 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.

## See Also

### Requesting previews

- [QLPreviewRequestCopyContentUTI(_:)](quicklook/qlpreviewrequestcopycontentuti(_:).md)
- [QLPreviewRequestCopyOptions(_:)](quicklook/qlpreviewrequestcopyoptions(_:).md)
- [QLPreviewRequestCopyURL(_:)](quicklook/qlpreviewrequestcopyurl(_:).md)
- [QLPreviewRequestCreateContext(_:_:_:_:)](quicklook/qlpreviewrequestcreatecontext(_:_:_:_:).md)
- [QLPreviewRequestFlushContext(_:_:)](quicklook/qlpreviewrequestflushcontext(_:_:).md)
- [QLPreviewRequestGetDocumentObject(_:)](quicklook/qlpreviewrequestgetdocumentobject(_:).md)
- [QLPreviewRequestSetDocumentObject(_:_:_:)](quicklook/qlpreviewrequestsetdocumentobject(_:_:_:).md)
- [QLPreviewRequestGetGeneratorBundle(_:)](quicklook/qlpreviewrequestgetgeneratorbundle(_:).md)
- [QLPreviewRequestGetTypeID()](quicklook/qlpreviewrequestgettypeid().md)
- [QLPreviewRequestIsCancelled(_:)](quicklook/qlpreviewrequestiscancelled(_:).md)
- [QLPreviewRequestSetDataRepresentation(_:_:_:_:)](quicklook/qlpreviewrequestsetdatarepresentation(_:_:_:_:).md)
- [QLPreviewRequestSetURLRepresentation(_:_:_:_:)](quicklook/qlpreviewrequestseturlrepresentation(_:_:_:_:).md)
