问题
I am new with epub. I have many different epub format files and i am going this file readable online.
I don't have much idea about what is in epub file ?
There is any way so i can know how many pages in my epub
file ?
I can do it using xml
, javascript
,PHP
or any other way if you have.
回答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.
回答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, anNCX
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
来源:https://stackoverflow.com/questions/40542479/count-total-number-of-pages-in-epub