13

Any idea how to implement 'page break' in epub reader? .epub is nothing but HTML pages, and epub reader renders those html pages. but i wonder how some epub readers like Adobe Digital Edition implemented page break. There,when we jump to any page, you will not find half displayed line(i.e only upper part of the letters visible and lower part will be in the next page) or half images where the other part in the next page. How to push the line to next page if i cannot display it completely in the current page?

2 Answers 2

16

In the underlying html, you can put something like this:

<span style="page-break-after: always" />
1
  • I use this css style to create page breaks. Works well in Stanza reader (iPhone) and Kindle (after conversion to Kindle format)
    – Larry K
    Mar 21, 2011 at 15:14
1

EPUB doesn't really have a concept of pages-- it's meant for reflowable content that flows to fit the dimensions of the display container. So what you're suggesting is a bit of a hack.

That said, users are comfortable with pages, and most readers implement some concept of a page.

What you will need is to implement something like Knuth's page-breaking algorithm, which in turn depends upon his paragraph, and line breaking algorithms. See his TeX book for the full literate code (IIRC, it's in Pascal). (It's not that complex a piece of code-- I implemented one in a desktop publishing program I wrote many years back).

If you went this route, it means you probably couldn't use a UIWebView.

BTW, Adobe Digital Edition implements a variation of Knuth's algorithm.

3
  • 6
    -1 since epubs definitely want page breaks before chapters, etc. How to do it: use a css rule such as div.chapter {page-break-after: always;}
    – Larry K
    Mar 21, 2011 at 15:18
  • if css3 is an option: column family (read the fine print in the W3C spec and you will see how to create fixed height/width column sizes) works wonders, and only requires a single container div the rest is math based on "portal" size (doing this in Java currently for use in a webview)
    – Dan
    Jul 8, 2011 at 15:23
  • Do you have a reference for Adobe Digital Edition's use of Knuth's algorithm? I knew for InDesign but not this one. Mar 25, 2014 at 1:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.