---
title: "UIGraphicsSetPDFContextURLForRect(_:_:)"
framework: uikit
role: symbol
role_heading: Function
path: "uikit/uigraphicssetpdfcontexturlforrect(_:_:)"
---

# UIGraphicsSetPDFContextURLForRect(_:_:)

Links a rectangular area on the current page to the specified URL.

## Declaration

```swift
func UIGraphicsSetPDFContextURLForRect(_ url: URL, _ rect: CGRect)
```

## Parameters

- `url`: The URL to open.
- `rect`: A rectangle on the current page of the PDF context.

## Discussion

Discussion You use this function to create external links within a PDF document. If the URL you specify is a type handled by a different application, tapping the rectangle opens that application. 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)
- [UIGraphicsEndPDFContext()](uikit/uigraphicsendpdfcontext().md)
- [UIGraphicsBeginPDFPage()](uikit/uigraphicsbeginpdfpage().md)
- [UIGraphicsBeginPDFPageWithInfo(_:_:)](uikit/uigraphicsbeginpdfpagewithinfo(_:_:).md)
- [UIGraphicsGetPDFContextBounds()](uikit/uigraphicsgetpdfcontextbounds().md)
- [UIGraphicsAddPDFContextDestinationAtPoint(_:_:)](uikit/uigraphicsaddpdfcontextdestinationatpoint(_:_:).md)
- [UIGraphicsSetPDFContextDestinationForRect(_:_:)](uikit/uigraphicssetpdfcontextdestinationforrect(_:_:).md)
