Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOC just wrong in random(?) ways #11

Open
raiju opened this issue Apr 11, 2016 · 5 comments
Open

TOC just wrong in random(?) ways #11

raiju opened this issue Apr 11, 2016 · 5 comments

Comments

@raiju
Copy link
Owner

raiju commented Apr 11, 2016

TOC positions seem to not be interpreted correctly, with an inconsistent error. Using the following code to generate a book:

$mobi = new MOBI();

$mobi_content = new MOBIFile();
$mobi_content->set("title", "My first eBook");
for($i = 0; $i < 20; $i++){
    $mobi_content->appendChapterTitle(($i+1)."这是什么鬼呀".($i+1));
    for($j = 0; $j < 20; $j++){
        $mobi_content->appendParagraph("P".($i+1).".".($j+1)." 许子晴娇嗲的戳了戳身边男子的手臂,小声抱怨了一句:“爸,你看你说的,我这不是见了偶像太兴奋了吗,哪有你这样拆自己闺女的台的……” ".($i+1).'-'.($j+1));
    }
    $mobi_content->appendPageBreak();
}
$mobi->setContentProvider($mobi_content);

$mobi->download("first.mobi");

and using the TOC for e.g. the 12th chapter breaks things.

@raiju
Copy link
Owner Author

raiju commented Apr 11, 2016

@bingool

@raiju
Copy link
Owner Author

raiju commented Apr 11, 2016

Sadly I can't find any documentation that might help figure out what is happening. The byte positions inside the text are exact (they point to the "<" at the start of the title entry), and yet it seems to lose more and more alignment as the book goes. Might be due to record splitting?

@raiju
Copy link
Owner Author

raiju commented Apr 11, 2016

As far as I can tell the byte positions are "correct" (as in, the filepos value corresponds to the number of bytes from the start to the position that is linked to). Note that as there is no spec, I can't be sure what the value of filepos should be. Also, others seem to be using the same strategy (e.g. Calibre w/ https://github.com/kovidgoyal/calibre/blob/ac8363713b8d82b33516c3806fc142bc04b5ace6/src/calibre/ebooks/mobi/writer2/serializer.py), even though the generated files have different (non-byte-aligned?) offsets?! The difference between the "true" byte distance and the one written by Calibre is, as far as I can tell, irregular, and yet the Kindle interprets it correctly... Not sure what's happening...

@raiju
Copy link
Owner Author

raiju commented Apr 11, 2016

This page: https://mokunosuke.wordpress.com/2012/03/14/%E7%AA%81%E7%A0%B4%E5%8F%A3%EF%BC%9F/ suggests that even kindlegen suffers from this problem. In any case, don't have the time to look deeper into this. Free for anyone to pick up ;)

@bingool
Copy link

bingool commented Apr 11, 2016

thank you very much.now the file can normal work , although it has the problem .so we can slowly to solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants