How to extract the currently visible text only from a UIWebView - ios

I am loading a XHTML file in a uiwebview and paginating its content by dividing its content in columns by using "-webkit-column" property.
I need to find out the currently visible text on a uiwebview not the entire one( the entire text can be easily found by using "document.body.innerText" property)
I tried using "elementFromPoint" to find the currently visible text but its not working.
Can anybody help in finding out this.

Related

PDFView display page number the way WKWebView shows for pdf

I am trying to use PDFKit for rendering pdf. But I could not find any way to highlight page number while scrolling, the way it is shown in WKWebView.
Do I need to make a custom logic for it?

Auto page break while creating PDF in iOS (Swift)

I have to create a PDF which contains data like a quotation document (text, tables, images, etc.). The data varies from 1 page to 3-4 pages. A table cell may have combination of text and images. Also, I have custom graphics to be rendered in PDF to show different shapes.
Example format:
I have tried PDFKit provided by Apple. I was able to draw individual parts. But I don't know how can I achieve auto page break mode (which shifts data to new page when there is no more space available in a page). One way to achieve this is that I have to calculate individual heights and divide data into pages as per available page size.
Is there any better way to do it using PDFKit?
I am also aware about creating PDF using UIGraphicsBeginPDFContextToData(). It also doesn't support auto page break. We have to call UIGraphicsBeginPDFPageWithInfo() for each new page.
I have also tried TPPDF and SimplePDF. Both don't support either page break on table or custom views.
I also can't go for HTML to PDF solution as I have custom views to be drawn in PDF.
Which is the best way in iOS to create PDF with above mentioned requirements?
"One way to achieve this is that I have to calculate individual heights and divide data into pages as per available page size." - this is the only way as PDFKit does not include automatic data layout and auto page breaks.

Positioning dynamic controls dynamically in iOS ViewController

First of all, let me tell you that I am new in Xamarin.
I am facing a problem in rendering controls dynamically on UI.
Approach I am using is: Xamarin.iOS
I have list of Questions having different Question Types
I loop through all questions and render them according to the question type.
Client wants to have HTML in Question Title, so that he can add any type of html tags including images, links etc in HTML. (I cannot use ‘NSAttributedString’ because it doesn’t support all HTML tags)
I am not using AutoLayout
I think UIStackView is a new control which is not available for older versions
Problem is, when I render UIWebView for QuestionTitle, and other control (let us say UITextField) for simple input from user, I do not know about the exact content length of Title (which is HTML) and therefore, I set default height of UIWebView as ‘100’ and once WebView is loaded, I set the height of webview according to the content size height. While rendering control, I calculate the Y-axis for every control to be rendered. When WebView is loaded, its height gets shrunk or expanded according to the size of content and therefore, the preceding sibling’s y-axis remains there since we don’t know how much siblings are there whose y-axis should be adjusted. (Keep in mind we have multiple webviews, as we have more than 1 question).
Is there any way, we can position all controls automatically (Just like we have LinearLayout in Android)?
Is there any better approach I can follow in order to resolve this kind of blocker?
I will really appreciate your help in this problem.

Adding multipage printing to Windows 8 ListView App

I have an app with a ListView showing a list of summary items.
I've added print support, but I'm stuck on splitting my content into different pages.
I can add multiple pages, but I don't know how to split my content into pages based on page size.
Currently I have a xaml user control for my print content with a bound ItemsControl in it. I'd either like to bind to a list of just the items that will fit on the page, or move the top visible item position up based on the page number.
I'm not sure which is the best approach and I'm not sure how to do either.
The only paging example I could find in the docs was for a rich text block, which relies on the RichTextBlockOverflow control. I don't think that will help me.

UIWebView locating text by touch

Would like to capture a touch on a UIWebView, map that to the relevant HTML text and insert a hyperlink into the HTML at that point.
Found a very nice reference to cleanly capture touches on UIWebView at:
http://mithin.in/2009/08/26/detecting-taps-and-events-on-uiwebview-the-right-way/
I've implemented it and it works very well.
Also found a very nice reference to search and highlight text in a UIWebView at:
http://www.icab.de/blog/2010/01/12/search-and-highlight-text-in-uiwebview/
I've implemented it [for a search feature] and it works very well.
But I can't quite make the intellectual jump from touch position [not text search] to a specific word in the UIWebView. Obviously this can be done, since touch-and-hold on a UIWebView triggers a "Copy or Define" popup which obviously knows the specific word you've pointed at.
The individual text nodes that JavaScript decodes from the DOM have no offsetLeft or offsetTop or offsetWidth or offsetHeight; I understand these need to be derived from the parent node.
But the individual text nodes can consist of many lines of text, depending on what the HTML source looks like. Potentially a single text node can contain an entire paragraph of text, hardly the one word that I'm trying to spot.
Can anyone suggest how "Copy or Define" can be so clever? Thanks.

Resources