Dynamically paginating .pub files in a UIWebView

I upload files from .epubin UIWebViewto display. Currently .epubdivided into separate files for each chapter. To display the chapters, I simply upload these files to UIWebView. I am trying to figure out how to paginate them depending on the font size, style, etc. This is tricky because iOS indirectly accesses the content UIWebView. Is there a standard way to break it down?

I am thinking about grabbing the full contents of a chapter from a page using JS and then breaking each chapter into pages based on the length of the line and lines on the page, but this seems crazy and I am having trouble returning to UIWebViewas valid html or javascript. (The text contains single quotes, etc.)

+3
source share
2 answers

Use UIWebView Pagination :)

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

To scale fonts you need to enter css thru javascript for the webkit font scaling property

http://css-infos.net/property/-webkit-text-size-adjust
+1
source

Use XmlHTTPRequest with "file: /// ... target" to load the content, it works.

0
source

Source: https://habr.com/ru/post/1774566/


All Articles