---
title: "setRect(_:forAnnotationKey:)"
framework: pdfkit
role: symbol
role_heading: Instance Method
path: "pdfkit/pdfannotation/setrect(_:forannotationkey:)"
---

# setRect(_:forAnnotationKey:)

Sets a rectangle value in the annotation’s dictionary.

## Declaration

```swift
func setRect(_ value: CGRect, forAnnotationKey key: PDFAnnotationKey) -> Bool
```

```swift
func setRect(_ value: NSRect, forAnnotationKey key: PDFAnnotationKey) -> Bool
```

## Parameters

- `value`: The rectangle value to set in the annotation’s dictionary.
- `key`: A doc://com.apple.pdfkit/documentation/PDFKit/PDFAnnotationKey or appropriate string from the Adobe PDF Specification.

## Return Value

Return Value true if the value sets successfully; otherwise, false.

## See Also

### Modifying Annotation Attributes

- [annotationKeyValues](pdfkit/pdfannotation/annotationkeyvalues.md)
- [value(forAnnotationKey:)](pdfkit/pdfannotation/value(forannotationkey:).md)
- [setValue(_:forAnnotationKey:)](pdfkit/pdfannotation/setvalue(_:forannotationkey:).md)
- [setBoolean(_:forAnnotationKey:)](pdfkit/pdfannotation/setboolean(_:forannotationkey:).md)
- [removeValue(forAnnotationKey:)](pdfkit/pdfannotation/removevalue(forannotationkey:).md)
- [PDFAnnotationKey](pdfkit/pdfannotationkey.md)
