Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DargonLee/85e960e44e3b752099a429823ba4cbd0 to your computer and use it in GitHub Desktop.
Save DargonLee/85e960e44e3b752099a429823ba4cbd0 to your computer and use it in GitHub Desktop.
func rtfDataToHtmlData(data: Data) -> Data? {
let attributedString = NSAttributedString(rtf: data, documentAttributes: nil)!
do {
let htmlData = try attributedString.data(from: NSRange(location: 0, length: attributedString.length), documentAttributes: [NSAttributedString.DocumentAttributeKey.documentType:NSAttributedString.DocumentType.html])
return htmlData
} catch {
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment