'Loading docx file into NSAttributesString not showing images (MacOS Swift)
I am loading docx data into an NSAttributedString, and then rendering it into an NSTextView. It mostly works, but it does not load the images, I checked the attributed string and it doesn't seem to have attachments after the load (that may be fine, not sure). Any ideas on why images are not loading, here is the code I use.
fileData = try NSData(contentsOfFile: filePath)
if let tryForString = try? NSAttributedString(data: fileData as Data, options: [
.documentType: NSAttributedString.DocumentType.officeOpenXML,
.characterEncoding: String.Encoding.utf8.rawValue
], documentAttributes: nil) {
fileString = tryForString
} else {
fileString = NSAttributedString("Data conversion error.")
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
