HTML book-like pagination

后端 未结 10 1333
清歌不尽
清歌不尽 2020-11-27 09:29

How can I split the content of a HTML file in screen-sized chunks to \"paginate\" it in a WebKit browser?

Each \"page\" should show a complete amount of text. This

相关标签:
10条回答
  • 2020-11-27 10:15

    You could split the pages in separate XHTML files and store them in a folder. Eg: page01, page02. You can then render those pages one by one underneath each other.

    0 讨论(0)
  • 2020-11-27 10:16

    You can look at http://www.litres.ru/static/OR/or.html?data=/static/trials/00/42/47/00424722.gur.html&art=424722&user=0&trial=1 but the code may be heavily obfuscated, so just use Firebug to inspect DOM.

    If the link isn't working, comment - would give you fixed.

    0 讨论(0)
  • 2020-11-27 10:19

    Speaking from experience, expect to put a lot of time into this, even for a barebones viewer. An ePub reader was actually first big project I took on when I started learning C#, but the ePub standard is definitely pretty complex.

    You can find the latest version of the spec for ePub here: http://www.idpf.org/specs.htm which includes the OPS (Open Publication Structure), OPF (Open Packaging Format), and OCF (OEBPS Container Format).

    Also, if it helps you at all, here is a link to the C# source code of the project I started on:

    https://www.dropbox.com/sh/50kxcr29831t854/MDITIklW3I/ePub%20Test.zip

    It's not fleshed out at all; I haven't played with this for months, but if I remember correctly, just stick an ePub in the debug directory, and when you run the program just type some part of the name (e.g. Under the Dome, just type "dome") and it will display the details of the book.

    I had it working correctly for a few books, but any eBooks from Google Books broke it completely. They have a completely bizarre implementation of ePub (to me, at least) compared to books from other sources.

    Anyway, hopefully some of the structural code in there might help you out!

    0 讨论(0)
  • 2020-11-27 10:19

    Had this same problem recently and inspired by the answers found a plain CSS solution using CSS3's column-* attributes:

    /* CSS */
    .chapter {
        width: 600px;
        padding: 60px 10px;
        -webkit-column-gap: 40px;
        -webkit-column-width: 150px;
        -webkit-column-count: 2;
        height:400px;
    }
    
    /* HTML */
    <div class="chapter">
        your long lorem ipsum arbitrary HTML
    </div>
    

    The example above gives great results on a retina iPhone. Playing around with the different attributes yields in different spacing between the pages and such.

    If you need to support multiple chapters for instance which need to start on new pages, there's an XCode 5 example on github: https://github.com/dmrschmidt/ios_uiwebview_pagination

    0 讨论(0)
提交回复
热议问题