how to implement 'page break' in epub reader
Asked Answered
S

2

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?

Schwa answered 11/5, 2010 at 7:1 Comment(0)
T
-3

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.

Toothsome answered 13/6, 2010 at 1:0 Comment(3)
-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;}Coruscation
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)Supply
Do you have a reference for Adobe Digital Edition's use of Knuth's algorithm? I knew for InDesign but not this one.Correlation
C
18

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

<span style="page-break-after: always" />
Carbamate answered 19/10, 2010 at 8:41 Comment(1)
I use this css style to create page breaks. Works well in Stanza reader (iPhone) and Kindle (after conversion to Kindle format)Coruscation
T
-3

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.

Toothsome answered 13/6, 2010 at 1:0 Comment(3)
-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;}Coruscation
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)Supply
Do you have a reference for Adobe Digital Edition's use of Knuth's algorithm? I knew for InDesign but not this one.Correlation

© 2022 - 2024 — McMap. All rights reserved.