Reading text and images from a pdf document in iOS

走远了吗. 提交于 2019-11-26 17:17:26

问题


I'm displaying locally stored pdf in my iPad application. Here's the code:

NSString *path = [[NSBundle mainBundle] pathForResource:@"About Downloads" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[pdfWebView loadRequest:request];

Now, by default, you can't copy text or images from the PDF which is rendered by the UIWebView. Is there a way to let users copy text and/or images out of pdf?

I'm not familiar with CATitledLayer, so i'm just wondering if it can help in this case?


回答1:


There's no simple answer to this. PDF's are nested dictionaries composed of more dictionaries & arrays. You'll have to dig into CGPDFDocument. Voyeur is an excellent tool to use while digging around in PDF's. Reader is a good suggested starting point for rendering PDF's.




回答2:


To get at the text in a PDF Document, I use PDF Kitten (https://github.com/KurtCode/PDFKitten). It works quite well, but as the author notes, is incomplete and does not support all font types.



来源:https://stackoverflow.com/questions/5732219/reading-text-and-images-from-a-pdf-document-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!