简体   繁体   English

计算epub中的总页数

[英]Count total number of pages in epub

I am new with epub. 我是epub新手。 I have many different epub format files and i am going this file readable online. 我有许多不同的epub格式文件,并且我将在线阅读此文件。 I don't have much idea about what is in epub file ? 我对epub文件中的内容不太了解? There is any way so i can know how many pages in my epub file ? 有什么办法可以让我知道我的epub文件中有多少页? I can do it using xml , javascript , PHP or any other way if you have. 如果可以的话,我可以使用xmljavascriptPHP或任何其他方式来实现。

Epub files are responsive ebooks which changes number of pages according to screen size. Epub文件是响应式电子书,可根据屏幕尺寸更改页面数。 Also the page numbers depends on the viewer application & device. 页码也取决于查看器的应用程序和设备。

An EPUB file is basically a ZIP file which contains: EPUB文件基本上是一个ZIP文件,其中包含:

  • a mimetype file for easy file type detection ( application/epub+zip ); 一个mimetype文件,用于轻松检测文件类型( application/epub+zip );
  • a META-INF/container.xml file describing the different types of publications contained in the EPUB file. 一个META-INF/container.xml文件,该文件描述了EPUB文件中包含的不同类型的发布。 Usually there is only one, but in principle you could have eg 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; 通常只有一个,但是原则上您可以在同一EPUB文件中包含例如相同文本的HTML和PDF版本,阅读应用程序或用户可以决定查看哪一个;
  • the OPF file (eg file.opf ) which is a manifest file containing: OPF文件(例如file.opf ),是包含以下内容的清单文件:
    • the metadata (title, author, etc.) 元数据(标题,作者等)
    • the list of assets inside the container (XHTML files, images, fonts, CSS stylesheets, etc.) 容器内的资产列表(XHTML文件,图像,字体,CSS样式表等)
    • 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. 一个TOC文件(EPUB 3中的XHTML文件,EPUB 2中的NCX文件),它描述目录,通常通过阅读应用程序进行分析以显示“目录”面板/窗口。

EPUB 3 files come in two renditions (ie, flavors): pre-paginated or reflowable , while EPUB 2 files are only reflowable . EPUB 3文件有两种格式(即风味): pre-paginatedreflowable ,而EPUB 2文件仅reflowable

pre-paginated (aka "fixed layout") means that the ebook is basically like a PDF, where each "page" has a pre-determined size, eg 800x600 px, but each page is written as a XHTML file instead of a binary blob. pre-paginated (又称“固定布局”)意味着电子书基本上就像PDF,其中每个“页面”都有预定的大小,例如800x600 px,但是每个页面都被编写为XHTML文件而不是二进制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. reflowable意味着没有预定的分页,因此文本“流动”以适应阅读设备的屏幕尺寸以及用户的字体高度/边距/行扩展选择。 It is basically like a Web site (= set of Web pages), packaged into a single ZIP file. 它基本上就像一个网站(=一组网页),打包成一个ZIP文件。 This is by far the most common flavor of EPUB. 这是迄今为止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. 因此,如果您具有pre-paginated EPUB,则可以通过简单地计算主干中的XHTML文件数来确定页面数,因为XHTML文件和页面之间必须存在一一对应的关系。

If you have reflowable EPUBs, there is no intrinsic concept of page. 如果您具有reflowable排的EPUB,则没有页面的固有概念。 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 (eg, 1024 characters/page). 一些阅读应用程序通过计算文本中的字符数,然后将该数字除以某个常数(例如,每页1024字符)来计算“页数”。 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 作为参考,完整的EPUB规范位于: http : //idpf.org/epub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM