我正在尝试从我的iOS应用程序生成pdf,其中pdf的内容在coldfusion中编码为base64。我能够获取base64string,但我无法使用以下代码对其进行解码:
let decodeData = NSData(base64EncodedString: base64String, options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters)
这是base64String的一部分
JVBERi0xLjQNJeLjz9MNCjEgMCBvYmoKPDwvRGVzY2VuZGFudEZvbnRzWzExOSAwIFJdL0Jhc2VGb250L1hJS1hIRitUaW1lc05ld1JvbWFuUFMtQm9sZE1UL1R5cGUvRm9udC9FbmNvZGluZy9JZGVudGl0eS1IL1N1YnR5cGUvVHlwZTAvVG9Vbmljb2RlIDEyMCAwIFI
答案 0 :(得分:0)
如果您仍在寻找答案:
if let decodeData = NSData(base64EncodedString: base64String, options: .IgnoreUnknownCharacters) {
yourWebView.loadData(decodeData, MIMEType: "application/pdf", textEncodingName: "utf-8", baseURL: NSURL(fileURLWithPath: ""))
} // since you don't have url, only encoded String