views:

757

answers:

2

Hi,

I am trying to page a webpage, so disable scrolling, then the second page is the same webpage scrolled down the page height.

The problem I have is that the bottom of the first page often has 1/2 a line of text, then the second page has the bottom half of the line.

Is there a way to ensure the entire line falls on one of the pages? Similar to Stanza etc?

Thanks

A: 

You have to paginate the web page into blocks that match the height of the UIWebView. If you cannot do that manually, or you want to support different devices and orientations, you will have to do it in Javascript.

I do not know of any fast way to measure and break text by rendered size in Javascript. This article may help, but what you need is a way to ask how much text fills a given space, not how much space a given text fills. The trimToPx method here only works for a single line and would be slow for a large body of text.

http://blog.mastykarz.nl/measuring-the-length-of-a-string-in-pixels-using-javascript/

There are some text measuring examples here as well.

The iPhone OS does not provide high level routines to break text by measurement, especially styled text, although I have not checked the 4.0 SDK. You can use CoreGraphics rendering to measure text but that is fairly difficult and would not support html.

drawnonward
Thanks for that, yeah its pretty messy unfortunately, just need to know if I need to bump up or down a few pixels to stop the lines being cut. Looks like its a deal breaker on my idea.
John
A: 

john, any solution you got for that.I am struggling for the same. I tried reading the file in bytes then adding br tag after fixed amount of text but the calculations wont come proper.

ashish
any help regarding the same.
ashish
any suggestions?
ashish
any help guys!!!
ashish
no luck sorry :( gave up
John
I am searching like anything on this from one month, no body is giving any right direction. Is this so difficult to do?
ashish