---
title: closePDF()
framework: coregraphics
role: symbol
role_heading: Instance Method
path: coregraphics/cgcontext/closepdf()
---

# closePDF()

Closes a PDF document.

## Declaration

```swift
func closePDF()
```

## Discussion

Discussion After closing the context, all pending data is written to the context destination, and the PDF file is completed. No additional data can be written to the destination context after the PDF document is closed.

## See Also

### Managing a PDF Graphics Context

- [beginPDFPage(_:)](coregraphics/cgcontext/beginpdfpage(_:).md)
- [endPDFPage()](coregraphics/cgcontext/endpdfpage().md)
- [addDestination(_:at:)](coregraphics/cgcontext/adddestination(_:at:).md)
- [setDestination(_:for:)](coregraphics/cgcontext/setdestination(_:for:).md)
- [setURL(_:for:)](coregraphics/cgcontext/seturl(_:for:).md)
- [addDocumentMetadata(_:)](coregraphics/cgcontext/adddocumentmetadata(_:).md)
