If you’ve ever used a eReader app that’s what I am trying to create. I want to load a HUGE amount of text, and then break it into pages. Those “page breaks” should occur when text starts to overflow or get cut off in any way. I’ve tried exploring a variety of ways to do this but I haven’t had much luck.
Right now I am trying to break every single word out (awful and slow) and measure how far from the top it is, after it gets to a certain height I am trying to edit the html to close the last page and start a new one.
I want to avoid separating the content after a certain number of characters or words since that is inconsistent. The document may have HTML in it too.
To be frank, I don’t even know where to start and I’ve been looking for some hint at how to proceed for quite a while.
Unfortunately, this is a non-trivial task. To give you some idea of what you’re up against, take a look at this: http://www.hpl.hp.com/techreports/2009/HPL-2009-123.pdf.
This question is similar: html pagination and 'paged media'
It would be nice if you could use the W3C paged media CSS standard, as suggested there but it’s not yet well supported in any of firefox, chrome or safari. Shocking but this appears to be one of the rare cases where IE is ahead of the curve.
I also strongly suspect that you should find a way to load segments of text. Loading HUGE amounts of text is going to hog up memory, slow down your page and generally muck up your user’s browser.