<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@T@NSAttributedStringDocumentReadingOptionKey"
  },
  "title" : "NSAttributedString.DocumentReadingOptionKey"
}
-->

# NSAttributedString.DocumentReadingOptionKey

Options for constructing an attributed string from data you read from disk.

```
struct DocumentReadingOptionKey
```

## Overview

The [`NSAttributedString.DocumentReadingOptionKey`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey) type defines attributes to use when creating an attributed string from data in a file. Use these strings with methods such as [`init(data:options:documentAttributes:)`](/documentation/Foundation/NSAttributedString/init(data:options:documentAttributes:)), [`init(HTML:options:documentAttributes:)`](/documentation/Foundation/NSAttributedString/init(HTML:options:documentAttributes:)), [`init(URL:options:documentAttributes:)`](/documentation/Foundation/NSAttributedString/init(URL:options:documentAttributes:)), [`read(from:options:documentAttributes:)`](/documentation/Foundation/NSMutableAttributedString/read(from:options:documentAttributes:)-5mbcx), and [`read(from:options:documentAttributes:)`](/documentation/Foundation/NSMutableAttributedString/read(from:options:documentAttributes:)-54wth) to specify expected details. For example, specify the [`documentType`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/documentType) attribute to interpret the file data as a specific file format.

## Topics

### Getting the document options

[`baseURL`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/baseURL)

The base URL for HTML documents.

[`characterEncoding`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/characterEncoding)

The string encoding.

[`defaultAttributes`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/defaultAttributes)

The default attributes to apply to plain files.

[`documentType`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/documentType)

The document type.

[`fileType`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/fileType)

The file type.

[`readAccessURL`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/readAccessURL)

The local files WebKit can access when loading content.

[`textEncodingName`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/textEncodingName)

The text encoding to use.

[`textSizeMultiplier`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/textSizeMultiplier)

The scale factor for font sizes.

[`timeout`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/timeout)

The time, in seconds, to wait for a document to finish loading.

[`webPreferences`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/webPreferences)

A WebPreferences object.

[`webResourceLoadDelegate`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/webResourceLoadDelegate)

An object to serve as the web resource loading delegate.

### Getting the font-scaling options

[`sourceTextScaling`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/sourceTextScaling)

The text-scaling mode to associate with the document’s content.

[`targetTextScaling`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/targetTextScaling)

The text scaling mode to use after reading the text from disk.

### Initializers

[`init(_:)`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/init(_:))

Creates a document reading option key with the specified raw value.

[`init(rawValue:)`](/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/init(rawValue:))

Creates a document reading option key with the specified raw value.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`Sendable`](/documentation/Swift/Sendable)

[`RawRepresentable`](/documentation/Swift/RawRepresentable)

---

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)