【发布时间】:2016-04-24 19:09:50
【问题描述】:
我想在我的UITextView .docx 中显示。没有外部库(我找不到)是不可能的。所以我尝试将(.docx 转换为.pdf).pdf 转换为.rft 并放入UITextView:
let rtf = NSBundle.mainBundle().URLForResource("2", withExtension: "rtf", subdirectory: nil, localization: nil)
let attributed = try NSAttributedString(fileURL: rtf, options:[NSDocumentTypeDocumentAttribute: NSRTFTextDocumentType], documentAttributes: nil)
textView.attributedText = attributed
有效,.rtf 文件显示在UITextView 中。但是,如果我手动进行复制和粘贴,转换 pdf 的过程不会保留他们弯曲的所有信息。如果我使用一个应用程序从糟糕变为更糟糕。
那么最好的方法是什么?
.pdf 和 .rtf 中相同部分的文本示例:
RTF 文件
【问题讨论】:
-
您需要您的用户编辑 UITextView 的文档还是仅仅查看它?如果您只需要查看 PDF,请使用 UIWebView。
-
用户不需要查看 PDF。但我想要一个更漂亮的外观。为了提高学习本文档的便利性。
-
所以澄清一下,他们不需要编辑文档,只需查看它?
-
他们不需要编辑文档。
标签: ios string swift nsstring type-conversion