<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/NSAttributedStringDocumentAttributeKey",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:@T@NSAttributedStringDocumentAttributeKey"
  },
  "title" : "NSAttributedStringDocumentAttributeKey"
}
-->

# NSAttributedStringDocumentAttributeKey

The attributes you apply to an entire document.

```
typedef NSString * NSAttributedStringDocumentAttributeKey;
```

## Discussion

The [`NSAttributedStringDocumentAttributeKey`](/documentation/UIKit/NSAttributedStringDocumentAttributeKey) 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

[`extern NSAttributedStringDocumentAttributeKey const NSDocumentTypeDocumentAttribute;`](/documentation/UIKit/NSDocumentTypeDocumentAttribute)

The document type.

  <doc://com.apple.documentation/documentation/AppKit/NSFileTypeDocumentAttribute>

  <doc://com.apple.documentation/documentation/AppKit/NSTextEncodingNameDocumentAttribute>

### Getting document metadata keys

  <doc://com.apple.documentation/documentation/AppKit/NSAuthorDocumentAttribute>

  <doc://com.apple.documentation/documentation/AppKit/NSCategoryDocumentAttribute>

[`extern NSAttributedStringDocumentAttributeKey const NSCharacterEncodingDocumentAttribute;`](/documentation/UIKit/NSCharacterEncodingDocumentAttribute)

The string encoding for the document.

[`extern NSAttributedStringDocumentAttributeKey const NSCocoaVersionDocumentAttribute;`](/documentation/UIKit/NSCocoaVersionDocumentAttribute)

The version of Cocoa that created the file.

  <doc://com.apple.documentation/documentation/AppKit/NSCommentDocumentAttribute>

  <doc://com.apple.documentation/documentation/AppKit/NSCompanyDocumentAttribute>

  <doc://com.apple.documentation/documentation/AppKit/NSConvertedDocumentAttribute>

  <doc://com.apple.documentation/documentation/AppKit/NSCopyrightDocumentAttribute>

  <doc://com.apple.documentation/documentation/AppKit/NSCreationTimeDocumentAttribute>

  <doc://com.apple.documentation/documentation/AppKit/NSEditorDocumentAttribute>

  <doc://com.apple.documentation/documentation/AppKit/NSKeywordsDocumentAttribute>

  <doc://com.apple.documentation/documentation/AppKit/NSManagerDocumentAttribute>

  <doc://com.apple.documentation/documentation/AppKit/NSModificationTimeDocumentAttribute>

[`extern NSAttributedStringDocumentAttributeKey const NSReadOnlyDocumentAttribute;`](/documentation/UIKit/NSReadOnlyDocumentAttribute)

An indication of whether the document is read-only.

  <doc://com.apple.documentation/documentation/AppKit/NSSubjectDocumentAttribute>

  <doc://com.apple.documentation/documentation/AppKit/NSTitleDocumentAttribute>

### Getting document appearance keys

  <doc://com.apple.documentation/documentation/AppKit/NSAppearanceDocumentAttribute>

[`extern NSAttributedStringDocumentAttributeKey const NSBackgroundColorDocumentAttribute;`](/documentation/UIKit/NSBackgroundColorDocumentAttribute)

The background color of the document.

  <doc://com.apple.documentation/documentation/AppKit/NSBottomMarginDocumentAttribute>

[`extern NSAttributedStringDocumentAttributeKey const NSDefaultFontExcludedDocumentAttribute;`](/documentation/UIKit/NSDefaultFontExcludedDocumentAttribute)

[`extern NSAttributedStringDocumentAttributeKey const NSDefaultTabIntervalDocumentAttribute;`](/documentation/UIKit/NSDefaultTabIntervalDocumentAttribute)

The default tab stop interval for the document.

  <doc://com.apple.documentation/documentation/AppKit/NSExcludedElementsDocumentAttribute>

[`extern NSAttributedStringDocumentAttributeKey const NSHyphenationFactorDocumentAttribute;`](/documentation/UIKit/NSHyphenationFactorDocumentAttribute)

The hyphenation factor of the document.

  <doc://com.apple.documentation/documentation/AppKit/NSLeftMarginDocumentAttribute>

[`extern NSAttributedStringDocumentAttributeKey const NSPaperMarginDocumentAttribute;`](/documentation/UIKit/NSPaperMarginDocumentAttribute)

The paper margin of the document.

[`extern NSAttributedStringDocumentAttributeKey const NSPaperSizeDocumentAttribute;`](/documentation/UIKit/NSPaperSizeDocumentAttribute)

The paper size for the document.

  <doc://com.apple.documentation/documentation/AppKit/NSPrefixSpacesDocumentAttribute>

  <doc://com.apple.documentation/documentation/AppKit/NSRightMarginDocumentAttribute>

[`extern NSAttributedStringDocumentAttributeKey const NSTextLayoutSectionsAttribute;`](/documentation/UIKit/NSTextLayoutSectionsAttribute)

The layout orientations for each section.

  <doc://com.apple.documentation/documentation/AppKit/NSTopMarginDocumentAttribute>

[`extern NSAttributedStringDocumentAttributeKey const NSViewModeDocumentAttribute;`](/documentation/UIKit/NSViewModeDocumentAttribute)

The view mode.

[`extern NSAttributedStringDocumentAttributeKey const NSViewSizeDocumentAttribute;`](/documentation/UIKit/NSViewSizeDocumentAttribute)

The view size.

[`extern NSAttributedStringDocumentAttributeKey const NSViewZoomDocumentAttribute;`](/documentation/UIKit/NSViewZoomDocumentAttribute)

The view zoom.

### Getting the font-scaling options

[`extern NSAttributedStringDocumentAttributeKey const NSSourceTextScalingDocumentAttribute;`](/documentation/UIKit/NSSourceTextScalingDocumentAttribute)

The text-scaling mode you used when creating the text.

[`extern NSAttributedStringDocumentAttributeKey const NSTextScalingDocumentAttribute;`](/documentation/UIKit/NSTextScalingDocumentAttribute)

The text-scaling mode to use when displaying the text.

### Getting the default attributes

[`extern NSAttributedStringDocumentAttributeKey const NSDefaultAttributesDocumentAttribute;`](/documentation/UIKit/NSDefaultAttributesDocumentAttribute)

The default document attributes.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)