---
title: NSAttributedString.DocumentAttributeKey
framework: foundation
role: symbol
role_heading: Structure
path: foundation/nsattributedstring/documentattributekey
---

# NSAttributedString.DocumentAttributeKey

The attributes you apply to an entire document.

## Declaration

```swift
struct DocumentAttributeKey
```

## Overview

Overview The NSAttributedString.DocumentAttributeKey type defines attributes that apply to an entire attributed string, and not to specific ranges of characters. You specify these attributes when writing an attributed string to disk, or reading text from a file on disk. Use these attributes to specify metadata about the overall document, including its author or title, page margin details, font-scaling options for cross-platform interchange, and more.

## Topics

### Getting document type keys

- [documentType](foundation/nsattributedstring/documentattributekey/documenttype.md)
- [fileType](foundation/nsattributedstring/documentattributekey/filetype.md)
- [textEncodingName](foundation/nsattributedstring/documentattributekey/textencodingname.md)

### Getting document metadata keys

- [author](foundation/nsattributedstring/documentattributekey/author.md)
- [category](foundation/nsattributedstring/documentattributekey/category.md)
- [characterEncoding](foundation/nsattributedstring/documentattributekey/characterencoding.md)
- [cocoaVersionDocumentAttribute](foundation/nsattributedstring/documentattributekey/cocoaversiondocumentattribute.md)
- [comment](foundation/nsattributedstring/documentattributekey/comment.md)
- [company](foundation/nsattributedstring/documentattributekey/company.md)
- [converted](foundation/nsattributedstring/documentattributekey/converted.md)
- [copyright](foundation/nsattributedstring/documentattributekey/copyright.md)
- [creationTime](foundation/nsattributedstring/documentattributekey/creationtime.md)
- [editor](foundation/nsattributedstring/documentattributekey/editor.md)
- [keywords](foundation/nsattributedstring/documentattributekey/keywords.md)
- [manager](foundation/nsattributedstring/documentattributekey/manager.md)
- [modificationTime](foundation/nsattributedstring/documentattributekey/modificationtime.md)
- [readOnly](foundation/nsattributedstring/documentattributekey/readonly.md)
- [subject](foundation/nsattributedstring/documentattributekey/subject.md)
- [title](foundation/nsattributedstring/documentattributekey/title.md)

### Getting document appearance keys

- [appearance](foundation/nsattributedstring/documentattributekey/appearance.md)
- [backgroundColor](foundation/nsattributedstring/documentattributekey/backgroundcolor.md)
- [bottomMargin](foundation/nsattributedstring/documentattributekey/bottommargin.md)
- [defaultFontExcluded](foundation/nsattributedstring/documentattributekey/defaultfontexcluded.md)
- [defaultTabInterval](foundation/nsattributedstring/documentattributekey/defaulttabinterval.md)
- [excludedElements](foundation/nsattributedstring/documentattributekey/excludedelements.md)
- [hyphenationFactor](foundation/nsattributedstring/documentattributekey/hyphenationfactor.md)
- [leftMargin](foundation/nsattributedstring/documentattributekey/leftmargin.md)
- [paperMargin](foundation/nsattributedstring/documentattributekey/papermargin.md)
- [paperSize](foundation/nsattributedstring/documentattributekey/papersize.md)
- [prefixSpaces](foundation/nsattributedstring/documentattributekey/prefixspaces.md)
- [rightMargin](foundation/nsattributedstring/documentattributekey/rightmargin.md)
- [textLayoutSections](foundation/nsattributedstring/documentattributekey/textlayoutsections.md)
- [topMargin](foundation/nsattributedstring/documentattributekey/topmargin.md)
- [viewMode](foundation/nsattributedstring/documentattributekey/viewmode.md)
- [viewSize](foundation/nsattributedstring/documentattributekey/viewsize.md)
- [viewZoom](foundation/nsattributedstring/documentattributekey/viewzoom.md)

### Getting the font-scaling options

- [sourceTextScaling](foundation/nsattributedstring/documentattributekey/sourcetextscaling.md)
- [textScaling](foundation/nsattributedstring/documentattributekey/textscaling.md)

### Getting the default attributes

- [defaultAttributes](foundation/nsattributedstring/documentattributekey/defaultattributes.md)

### Initializers

- [init(_:)](foundation/nsattributedstring/documentattributekey/init(_:).md)
- [init(rawValue:)](foundation/nsattributedstring/documentattributekey/init(rawvalue:).md)

## Relationships

### Conforms To

- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [RawRepresentable](swift/rawrepresentable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Getting document-wide attributes

- [NSAttributedString.DocumentReadingOptionKey](foundation/nsattributedstring/documentreadingoptionkey.md)
- [HTML attributes](foundation/html-attributes.md)
- [NSAttributedString.DocumentType](foundation/nsattributedstring/documenttype.md)
- [NSAttributedString.TextLayoutSectionKey](foundation/nsattributedstring/textlayoutsectionkey.md)
- [NSTextScalingType](uikit/nstextscalingtype.md)
