One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
bbongrip
9 years agoHelpful | Level 6
convert downloaded pdf file to human readable string
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
- Greg-DB
Dropbox Staff
It sounds like the Dropbox portion of this is working properly, so I'm afraid I can't offer much insight.
That is, the PDF data is getting downloaded, and how your app handles that data is up to you. PDF data isn't necessarily human-readable though, so this may not just be a matter of encoding string properly. I recommend reading about the PDF format to see how you can extract the information you're looking for.- bbongripHelpful | Level 6ok. Thanks again Greg
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,950 PostsLatest Activity: 12 hours ago
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!