Reputation: 1355
I need to add a PDF search functionality in iPad, I have a number of PDF files that need to be searched and highlighted based on a text input in a text box. Anyone has any experience with libraries or has done it before?
Thanks.
Upvotes: 1
Views: 392
Reputation: 2272
Hello mate here are apple developer docs: https://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf_scan/dq_pdf_scan.html#//apple_ref/doc/uid/TP30001066-CH220-TPXREF101
In quartz there is api for scanning pdf document. Search on stack overflow for CGPDFScanner, you can find a bunch of suggestions.
However real answer here is in case you don't have moths to waste, do not try to implement pdf parsing yourself. It will drive you mad. Im speaking from experience. Apple only provides api for scanning pdf tags not parsing them. Problem here is complexity of pdf format itself. Here are docs http://www.adobe.com/devnet/pdf/pdf_reference.html its over 800 pages. I have read it all. For instance if you wanted to highlight the text you would have to know its position as well as its representation is some encoding. These information are extremely difficult to recover reliably. If I remember correctly you have two ways to write text. One of these ways has 4 different tags that text is wrapped around, plus seven different encoding, some of these have to be mapped to font dictionaries, witch have number of different ways of mapping and encoding. And this is just getting text out to readable string.
Long story short, this seems like it should be very easy but trust it isn't, I looked into it last year and wasn't able to find reliable library. I tried to implement it myself and after a month I had to give up. Unless you have a team of people, it will be very difficult task.
Upvotes: 2