iOS How to get all words coordinates in PDF page

随声附和 提交于 2019-12-11 20:59:18

问题


I have looked through many tutorials and usually stack users trow links to the pdfkitten, but as I've tested it I have not satisfied with result. So the search does not work with multiply word and etc.

So what I am looking for I need to get all words from the pdf page and highlight it if the words cross some rectangle.


回答1:


I used PDFKitten for the same.

  • What I did was while scanning the PDF - Identify the words separated by spaces.
  • Save the RenderingState(Model in PDFKitten code)word is encountered save that word in a model with it's current RenderingState (Model in PDFKitten code) which will be initial state. When the complete word is found(space separated) again save the current RenderingState as final state.
  • The code for converting RenderingState to actual view's frame using above initial state and final state, is present in PDFKitten. You can refer to that code.
  • apply current media box transform to frame.
  • And finally don't forget to convert resulted frame into user's co-ordinate system. Otherwise you will observe the reverse effect.


来源:https://stackoverflow.com/questions/24189458/ios-how-to-get-all-words-coordinates-in-pdf-page

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