Highlighting a string in a pdf iphone - iphone

I'm developing a book app.My client has provided all the contents of pdf.
I have already implemented all the contents of pdf to book.
But he wanted to highlight a text in that pdf.
The user would like the text to allow for highlighting (like if you're reading a paper book).
Is this possible? Can anyone help me on this, please?
Thanks in advance.

Theoretically yes.. depends on a bit hacking and other things, for example fonts used in the PDF. Have a look at PdfKitten, their demo project can find text in a PDF and highlight it. That should give you a first pointer on how to highlight. If you want to the user to highlight with the touches you would need to be able to transform locations of touches into the PDF to determine where exactly the user touched, but it should be possible.

Related

How to select text in DTAttributedTextView?

I'm using DTCoreText DTAttributedTextView in my app to highlight the urls in my text. My other criteria is to be able to select by tapping and holding similar to UITextView. However, DTAttributedTextView doesn't seem to to use a UITextView as a placeholder. Anybody has an idea how I can achieve this?
Thanks
That's a feature that's only available via the paid version of DTCoreText.
from the github page
This is useful for drawing simple rich text like any HTML document without having to use a UIWebView. For text selection and highlighting (as you might need for an Editor or Reader) there is the commercial DTRichTextEditor component which can be purchased in the Cocoanetics Parts Store.

How to highlight text in epub like ibooks app

I need to highlight text in epub book,when user selects the text,i can get the text,what the user has selected,but i need to highlight,the text permanently what user selected,thanks,any help will ne appreciated.
There's nothing built in to iOS that will do this. Some broad techniques that might work:
If you're showing the book in a web view, you might be able to wrap that area in a span and style it to create a highlight.
If you're using Core Text, you could draw the highlight in directly, either before or after drawing the text. (Your choice will decide how the highlight affects non-black text.)
You could add a transparent view over the text that draws in the highlight.
As for adding highlight-related items to the selection menu, see this Stack Overflow post. You probably won't be able to get icons in the menu like Apple does, though; that seems to be a private API. You could probably override the whole menu system if you want something closer to Apple's look, but that'll be quite a bit of work.

Make pdf reader like functionality in my app (highlight the content)

I need a functionality like in the iphone pdf reader.
i want that user select some text content and that content should be highlighted with yellow color.
Currently i am using text view and want to know that can i achieve same functionality in it.
or i have to shift to pdf ?
Please tell that how to achieve that in either of the two.
You can try NSAttributedString-Additions-for-HTML
Take a look at EGOTextView
A drop-in replacement for UITextView that amongst other things supports attributed strings. This would allow you to achieve your aim of selecting text, and then applying a style to that selection such as a yellow highlight.

Is CoreText just a draw/layout Framework for text?

Im using CoreText to display some text, creating framesetter, frames and so, and everything is fine. I can even format the text, but this all is done before I draw. Now the question that is driving me crazy:
CoreText is just to render text? I cannot get any reference to CTRuns or Glyphs to highlight them?
Another sub big question, the Pages App dont use CoreText, anyone knows? In Pages, you can select any already drawn styled text!
All I want is to draw the text and be able to let the user tap to select any text or doubleTap to select the paragraph.
Please, anyone, any light?
Thanks in advance.
CoreText is just to render text. Implementing user interaction is quite another matter. You need to implement UITextInput protocol, see here. It's a big job.
If you just want to input text and don't have a need for advanced typography, just use UITextView or UIWebView.
you can get image bounds of CTLines and CRRuns via core text here is little example i made for my app it's not perfect yet but you can get a little idea of how it works.
textViewProject

Searching text from UITextView in iPhone

I'm developing an application for the iPhone where some text is shown in a UITextView. I want to search for a specific word in the text and then show the text with that specific word colored. If anyone can help me solve this, I'll be very glad.
UITextView does not allow any formatting of the text within it. If the text is static (i.e. doesn't need to be edited), use a UIWebView instead; that will allow you to apply HTML formatting.
If a web view isn't an option, your best bet will be to try to calculate where the text in question will fall in the text view and then draw some sort of highlight around it. NSString has some methods to calculate how much space you need to draw a given string on screen; by being very, very clever with those methods, you may be able to work out where the word you're trying to highlight is. Unfortunately, this will not be at all simple.
If you do come up with a solution, everyone here would probably love to hear about it!