Skip to content Skip to sidebar Skip to footer

Count Total Number Of Pages In Epub

I am new with epub. I have many different epub format files and i am going to make this files readable online. I don't have much idea about what is in epub file ? There is any way

Solution 1:

Epub files are responsive ebooks which changes number of pages according to screen size. Also the page numbers depends on the viewer application & device.


Solution 2:

An EPUB file is basically a ZIP file which contains:

  • a mimetype file for easy file type detection (application/epub+zip);
  • a META-INF/container.xml file describing the different types of publications contained in the EPUB file. Usually there is only one, but in principle you could have e.g. the HTML and PDF versions of the same text inside the same EPUB file, and the reading app or user can decide which one to view;
  • the OPF file (e.g. file.opf) which is a manifest file containing:
    • the metadata (title, author, etc.)
    • the list of assets inside the container (XHTML files, images, fonts, CSS stylesheets, etc.)
    • the spine, that is, the default reading order of the publication
  • a TOC file (an XHTML file in EPUB 3, an NCX file in EPUB 2), which describes the table of contents and it is usually parsed by reading applications to show the "Table of Contents" panel/window.

EPUB 3 files come in two renditions (i.e., flavors): pre-paginated or reflowable, while EPUB 2 files are only reflowable.

pre-paginated (aka "fixed layout") means that the ebook is basically like a PDF, where each "page" has a pre-determined size, e.g. 800x600 px, but each page is written as a XHTML file instead of a binary blob. This type of rendition is used for illustrated and children's books, where exact placement of images is crucial.

reflowable means that there is no pre-determined pagination, hence the text "flows" to adapt to the reading device screen size and to the font height/margin/line spread choices of the user. It is basically like a Web site (= set of Web pages), packaged into a single ZIP file. This is by far the most common flavor of EPUB.

As a consequence, if you have pre-paginated EPUBs, you can determine the number of pages by simply counting the number of XHTML files in the spine, since there must be a one-to-one correspondence between XHTML files and pages.

If you have reflowable EPUBs, there is no intrinsic concept of page. Some reading applications compute the "number of pages" by counting the number of characters in the text, and then dividing this number by some constant (e.g., 1024 characters/page). But of course this is just a rough estimate and it does not necessarily correspond to the number of "screens" needed to display the text, which, again, depends on the typographical choices of the reading application and the user (font size, margin, line spread, etc.). Some other reading applications just display a % progress, computed using the number of characters of the text seen so far divided by the total number of characters in the text.

For reference, the full EPUB specification is here: http://idpf.org/epub


Post a Comment for "Count Total Number Of Pages In Epub"