iPhone UIWebView epubs split page by page - iphone

It's really interesting how book reading applications like Stanza or Eucalyptus split epubs which is html by page so lines are clear and next page starts at the correct line.
Does anyone has any idea how this could be accomplished?

The easiest way is to render a chapter inside an epub in a UIWebView and the use javascript to compute page boundaries. The interface between Cocoa and JS is kind of tricky but stringByEvaluatingJavaScriptFromString: can be used to run JS inside a UIWebView.
Once you have the page boundaries you can scroll the chapter using window.scrollTo(x,y); and adjust the size of your UIWebView according to your page boundaries to prevent any incomplete lines showing from the bottom.

Related

Get only currently visible text

I know I can get the whole body of a document with context.document.body.getOoxml() and the current selection with context.document.getSelection(), however I can't find a way to establish what is currently on screen and what is not...
Is there a method in the Word Office JS api to retrieve only the content currently displayed on the screen?
There isn't a solution for this. The way some of the JavaScript libraries in web pages are able figure out this problem is through the view port.
Example here: https://www.customd.com/articles/13/checking-if-an-element-is-visible-on-screen-using-jquery
See another helpful SO answer here: Get the browser viewport dimensions with JavaScript
Now - Word however uses HTML as a way of formatting - and not as a way of directly displaying things. So even if you could run the same library on the HTML - it wouldn't have the same context.
The best you could do is to get the height of the visible space (which should be the same height as your add-in frame) and attempt to do some mapping. You would have some weird edge cases though, like if the font-size is different, or you have a page-break in the view etc...

setting view port before loading HTML page in iOS

I am an iOS developer and i do not have any knowledge about web development.I am trying to load an HTML page on UIWebView since the content size of web page is larger then the iOS device screen size,the webview shows scroll bars which has to be avoided in my case.I want to fit the page to the webview width.
I did read some posts here and understood that i should change the viewport of HTML to get things work as i desired.When i manually change the width and height properties of meta tag in HTML its fitting to my webview.What is the best method to change the view port before loading page.
(I have seen approaches to set scale using stringByEvaluatingJavaScriptFromString: in webViewDidFinishLoading: and i can not prefer doing this because the webview takes time to load the content till then it shows the scalled page then it refreshes.)
Is there any better method to change meta propertied then reading HTML file in to NSString and do poor string level manipulations?The HTML pages are always available locally on the device.
Please help,i need to get it fixed as soon as possible.

How do I delay page display until JS is done?

I've done the prerequisite searching of stackoverflow and looking on the internet. I suspect that the answer is ' This can't be done. ' but I'm hoping someone here might have a solution.
My page loads fine, but many of my YUI components don't fully load before being displayed. For example, my DataTable will resize itself when displaying or my buttons will appear in their native form and then get YUI-fied.
Is there a way to delay the displaying of the page until all the Javascript is finished (i.e. all my YUI components are finished rendering)? I don't know how this would happen, as a lot of the JS depends on the DOM being present to manipulate it.
Is there a way to delay the displaying
of the page
If I understand correctly you would like to hide it until it's done?
If that's the case I have an idea:
add a wrapper around the element you
want to hide (or use
position:absolute to cover it)
give that div a background which use
the color of the surrounding with a
positive z-index
when all your javascript has loaded remove the
z-index or change the color of the background to transparent
Your javascript code would look like this:
do 1. and 2.
load your js
do 3.
Of course it needs to be synchrone.
As an alternative you could use visibility:hidden / visible on the element itself but I dunno for sure if it's well supported.
Try putting your Javascript in the head section of the page, as if it's near the end of the page, it'll load later (making the first elements load faster). OR, better yet, serve up your Javascript compressed and via a CDN, such as Amazon CloudFront so that it loads quickly.

iPhone - view PDF like in iBooks

I have question about view for displaying multipage PDFs in my app. I have found solutions with webview but they lack ability to zoom and scroll between pages horizontally. Also found solutions using Quartz2D but the same problem as above.
Is there any way to present PDF like in iBooks? You can pinch-i/out zoom, list between pages horizontally. And also how to do taht with single PDF file, not split PDF to pages.
Thanks a lot.
Update: 04 Feb 2012
Check out this project, it's opensource and very well made:
Project:
http://www.vfr.org/
Source:
https://github.com/vfr/Reader
I can't give you the answer, but i can redirect you to a example project that is able to load and render a multipage pdf page by page.
To be honest this application it's manly on the iBook curl effect (forget it, it's a private API, no way) but inside there is a class that render on a view a pdf page, I'm sure that if you play a little with that code, CGAffineTransformMakeScale, CGAffineTransformMakeTranslation and touch control you will be able to obtain that effect.
Link to the project:
http://blog.steventroughtonsmith.com/2010/02/apples-ibooks-dynamic-page-curl.html
Checkout this sample code from Apple:
http://developer.apple.com/library/ios/samplecode/ZoomingPDFViewer/Introduction/Intro.html
It tells you how to efficiently display and zoom PDF documents.
For paging, see this link:
http://www.random-ideas.net/posts/42
Between the two of those you should be all set.

Should I use UIWebView or UITextView to display text in an e-book reader app?

I want to make an e-book reader iPhone app. Should I use UITextView or UIWebView to display the text? Which control is used by other e-book readers?
I would use a UIWebView, as it gives you much more flexibility in the presentation of the text. According to the UITextView Class Reference:
This class does not support multiple
styles for text. The font, color, and
text alignment attributes you specify
always apply to the entire contents of
the text view. To display more complex
styling in your application, you need
to use a UIWebView object and render
your content using HTML.
Also, UITextView uses scrolling to display large amounts of text (it inherits from UIScrollView); in an e-book reader, you will most likely want to paginate the content, so you will not want the scrolling behaviour.
UIWebView is much better solution than UITextView mainly due to support of rich formatting of its contents. On the other hand you will miss some very important functions which you get for free while using UITextView. I'm talking mostly about searching inside, changing contents size etc. All of this is possible with UIWebView but it's not straightforward - css & javascript are for the help here
Did you get highlight functionality for this as font size can change. Save them for future so that when ever he came to same page can see them
U should use UIWEB view ,as to provide paragraph and other functions of text are not supported by text view, u can directly implement html code and can make the app with proper view of text. So my suggestion is to use web view.