orthros / dart-epub

Epub Reader and Writer for Dart
MIT License
218 stars 226 forks source link

Exception: Incorrect EPUB spine: TOC is missing #38

Closed arkanmgerges closed 5 years ago

arkanmgerges commented 6 years ago

Hi, Please can you check this epub book ? Year Five Maths: Operations on Numbers

The part of the code:

  _readEpubFile(String filePath) async {
    var targetFile = new io.File(filePath);
  List<int> bytes = await targetFile.readAsBytes();
  EpubBook epubBook = await EpubReader.readBook(bytes);
EpubContent bookContent = epubBook.Content;

Map<String, EpubTextContentFile> htmlFiles = bookContent.Html;
StringBuffer sb = StringBuffer();

 htmlFiles.values.forEach((EpubTextContentFile htmlFile) {
   String htmlContent = htmlFile.Content;
   sb.write(htmlContent);
 });

It's throwing an exception:

E/flutter ( 7117): #15     _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143:19)
E/flutter ( 7117): #16     _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
E/flutter ( 7117): #17     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
E/flutter ( 7117): #18     _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7)
E/flutter ( 7117): #19     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7)
E/flutter ( 7117): #20     _invoke1 (dart:ui/hooks.dart:142:13)
E/flutter ( 7117): #21     _dispatchPointerDataPacket (dart:ui/hooks.dart:99:5)

Thanks

lokios commented 5 years ago

AS per epub 3.X, latest specification since 2011 , The TOC attribute optional.

https://www.w3.org/publishing/epub3/epub-packages.html#sec-spine-elem However the dart packaged code is taking this as mandatory and throwing validation errors for almost all of Reference samples: https://idpf.github.io/epub3-samples/30/samples.html

To author: How soon can we FIX this? You may try any of the expub samples , the code will throw TOC attribute missing validations errors

Thanks

orthros commented 5 years ago

This should be fixed in version 2.1.0