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


CGContextRef QLPreviewRequestCreatePDFContext(QLPreviewRequestRef preview, const CGRect *mediaBox, CFDictionaryRef auxiliaryInfo, CFDictionaryRef properties);



The preview request object.


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 CGPDFContextCreate.


A dictionary containing PDF auxiliary information. See the description of the auxiliary dictionary keys in CGPDFContext for more information about the keys and values of this dictionary.


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.


Be sure to bracket each PDF page written to the context with CGPDFContextBeginPage and CGPDFContextEndPage 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.