mertakdut / EpubParser

Parses .epub files, provides seperation page by page.
Apache License 2.0
118 stars 27 forks source link

how to read all chapters title? #17

Closed epubreader closed 7 years ago

epubreader commented 7 years ago

how to read all chapters title? thanks.

mertakdut commented 7 years ago

Hello,

It's not possible to read chapter titles from an epub file if they're not defined chapter by chapter in toc.ncx file. Though we can read all navigation points from toc.ncx. EpubParser splits the book content by navigation points as well as maxContentPerSection.

Navigation Points Example:

`<pageTarget value="4" type="front" id="pt-4" playOrder="5">
  <navLabel>
    <text>[v]</text>
  </navLabel>
  <content src="@public@vhost@g@gutenberg@html@files@28885@28885-h@28885-h-0.htm.html#Page_v"/>
</pageTarget>
<pageTarget value="5" type="front" id="pt-5" playOrder="6">
  <navLabel>
    <text>[vi]</text>
  </navLabel>
  <content src="@public@vhost@g@gutenberg@html@files@28885@28885-h@28885-h-0.htm.html#Page_vi"/>
</pageTarget>`

In the example, fifth navigation point has the title [v] while sixth has [vi]. These navigation points are predefined and can be anything. Titles may be meaningless, navigation points don't have to split the book chapter by chapter etc.

In conclusion, reading chapters of given epub file is impossible (as far as I know), but I can share the toc.ncx file's navigation points (pageTargets in the example) if it solves your problem.

mertakdut commented 7 years ago

Check out how to get all navigation points in the toc.ncx file.