---
title: UIGraphicsEndPDFContext()
framework: uikit
role: symbol
role_heading: Function
path: uikit/uigraphicsendpdfcontext()
---

# UIGraphicsEndPDFContext()

Closes a PDF graphics context and pops it from the current context stack.

## Declaration

```swift
func UIGraphicsEndPDFContext()
```

## Discussion

Discussion You must call this function after you finish drawing to a PDF graphics context. This function closes the current open page and removes the PDF context from the graphics context stack. It also releases the CGContext associated with the PDF context.  If the current graphics context is not a PDF context, this function does nothing.

## See Also

### PDF creation

- [UIGraphicsBeginPDFContextToData(_:_:_:)](uikit/uigraphicsbeginpdfcontexttodata(_:_:_:).md)
- [UIGraphicsBeginPDFContextToFile(_:_:_:)](uikit/uigraphicsbeginpdfcontexttofile(_:_:_:).md)
- [UIGraphicsBeginPDFPage()](uikit/uigraphicsbeginpdfpage().md)
- [UIGraphicsBeginPDFPageWithInfo(_:_:)](uikit/uigraphicsbeginpdfpagewithinfo(_:_:).md)
- [UIGraphicsGetPDFContextBounds()](uikit/uigraphicsgetpdfcontextbounds().md)
- [UIGraphicsAddPDFContextDestinationAtPoint(_:_:)](uikit/uigraphicsaddpdfcontextdestinationatpoint(_:_:).md)
- [UIGraphicsSetPDFContextDestinationForRect(_:_:)](uikit/uigraphicssetpdfcontextdestinationforrect(_:_:).md)
- [UIGraphicsSetPDFContextURLForRect(_:_:)](uikit/uigraphicssetpdfcontexturlforrect(_:_:).md)
