Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically Paginating .epub files in UIWebView

Tags:

ios

uiwebview

I am loading files from an .epub into UIWebViews for display. At the moment, the .epub is divided into individual files for each chapter. To display the chapters, I am just loading these files into UIWebView. I am trying to figure out how to break these down into pages depending on font size, styling, etc. It's proving difficult, as iOS only accesses the UIWebView content indirectly. Is there a standard method for breaking it up?

I'm thinking about grabbing full chapter content out of a page with JS, then breaking each chapter down into pages based on line length and lines per page, but that seems sort of crazy, and I'm having trouble returning it to a UIWebView as valid html or javascript code. (The text contains single quotes, etc.)

like image 841
Chris Avatar asked Nov 20 '25 06:11

Chris


1 Answers

Use UIWebView Pagination :)

myWebView.paginationMode = UIWebPaginationModeLeftToRight;
myWebView.paginationBreakingMode = UIWebPaginationBreakingModePage;
myWebView.gapBetweenPages = 50;

For font scaling, you need to inject css thru javascript for webkit's font scaling property

http://css-infos.net/property/-webkit-text-size-adjust
like image 83
Marc-Alexandre Bérubé Avatar answered Nov 21 '25 20:11

Marc-Alexandre Bérubé



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!