Im downloading a pdf file from dropbox that I've previously saved to dropbox, created progamatically using HTML Markup. (which is working fine). But I then want to convert the pdf file to a human readable String so that I can gather specific info from that string. heres what i've been trying but its not giving me a human readable string.
/** Download pdf file from dropbox **/
// Verify user is logged into Dropbox
if let dropboxClient = DropboxClientsManager.authorizedClient {
// Download File from Dropbox
let filename = ((cell?.textLabel?.text)! + ".pdf").lowercased()
print(filename)
dropboxClient.files.download(path: "/\(filename)").response { response, error in
if let response = response {
let responseMetadata = response.0
print("dropbox responseMetadata: \(responseMetadata)")
let fileContents = response.1 as NSData
print("dropbox fileContents: \(fileContents.description)")
let encodedFile = String(data: fileContents as Data, encoding: String.Encoding.ascii)
print("ACTUAL FILE: \(encodedFile?)")
} else if let error = error {
print("dropbox error: \(error)")
}
}
}
I believe Im having trouble using the proper String.encoding, but i've tried most of them and nothing seems to work. Any help is much appreciated. Thanks