---
title: "rtfdFileWrapper(from:documentAttributes:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsattributedstring/rtfdfilewrapper(from:documentattributes:)"
---

# rtfdFileWrapper(from:documentAttributes:)

Returns a file wrapper object that contains an RTFD document corresponding to the characters and attributes within the specified range.

## Declaration

```swift
func rtfdFileWrapper(from range: NSRange, documentAttributes dict: [NSAttributedString.DocumentAttributeKey : Any] = [:]) -> FileWrapper?
```

## Parameters

- `range`: The range.
- `dict`: A required dictionary specifying the document attributes. The dictionary contains values from Document Types and must at least contain NSDocumentTypeDocumentAttribute.

## Return Value

Return Value A file wrapper containing the RTFD data.

## Discussion

Discussion The file wrapper also includes the document-level attributes in docAttributes, as explained in RTF Files and Attributed Strings. Raises an rangeException if any part of aRange lies beyond the end of the receiver’s characters. You can save the file wrapper using the write(toFile:atomically:updateFilenames:) method of FileWrapper.

## See Also

### Exporting the string as data

- [data(from:documentAttributes:)](foundation/nsattributedstring/data(from:documentattributes:).md)
- [fileWrapper(from:documentAttributes:)](foundation/nsattributedstring/filewrapper(from:documentattributes:).md)
- [docFormat(from:documentAttributes:)](foundation/nsattributedstring/docformat(from:documentattributes:).md)
- [rtf(from:documentAttributes:)](foundation/nsattributedstring/rtf(from:documentattributes:).md)
- [rtfd(from:documentAttributes:)](foundation/nsattributedstring/rtfd(from:documentattributes:).md)
