开发者

HIghlighting the text in PDF document iPhone xcode

Hii friends, i am developing a e Book using a web view where i am loading the web view with PDF document.Now i want to develop the search functionality but i am not unserstanding how to implement it.So kindly give me a solution,

Thank开发者_如何学编程s in advance.


Instead of using UIWebView, you might want to look into using Quartz 2D's CGPDFDocumentRef and parsing a CGPDFDictionary for strings of interest.

Once your know which PDF dictionary elements contain your text and where they are located, you might be able to highlight that text with other Quartz 2D routines.

Another option might be to convert your PDF document to RTF or HTML formats, either of which would probably be easier to parse and edit to add highlighting.


it seems not an easy work, here is my thought.

Instead of using CGContextDrawPDFPage in Quartz2D, you may need to layout the page yourself for getting the CGRect of the text for highlight.

  1. Parse PDF page content to PDF objects.
  2. Combine the PDF objects in binary form or other forms to the objects you can use in Core Text/CoreGraphics, like CTFontDescriptorRef, PDF operators binary streams
  3. Use Core Text/CoreGraphics function to layout the text/graphics from the fonts/text/images/pdf graphic operators, and then you can get the position and rect
  4. return a CGRect, and highlight that CGRect using CoreGraphics functions
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜