$book->addChapter("Chapter 7.1.3.2", "Chapter007132.html", $content_start . "<h2>Chapter 7.1.3.2</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir); $book->addChapter("Chapter 7.1.3.3", "Chapter007133.html", $content_start . "<h2>Chapter 7.1.3.3</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir); $book->addChapter("Chapter 7.1.3.4", "Chapter007134.html", $content_start . "<h2>Chapter 7.1.3.4</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir); $log->logLine("Add Chapter 7.2.0.0"); // We went deep with Chapter 7.1.3.x, and sometimes the generating class knows exactly where it is anyway, // so instead of relying on multiple ->backLevel() calls, you can set the target level directly. // This only works for going back in the hieracy. ->setCurrentLevel(1) (or less) equals ->rootLevel(); $book->setCurrentLevel(2); $book->addChapter("Chapter 7.2", "Chapter00720.html", $content_start . "<h2>Chapter 7.2.0</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir); $log->logLine("Add Chapter 7.3.0.0"); $book->addChapter("Chapter 7.3", "Chapter00730.html", $content_start . "<h2>Chapter 7.3.0</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir); $log->logLine("Add Chapter 7.3.1.0"); $book->subLevel(); $book->addChapter("Chapter 7.3.1", "Chapter00731.html", $content_start . "<h2>Chapter 7.3.1</h2>\n" . $chapter7Body, false, EPub::EXTERNAL_REF_ADD, $fileDir); // If you have nested chapters, you can call ->rootLevel() to return your hierachy to the root of the navMap. $book->rootLevel(); $log->logLine("Add TOC"); $book->buildTOC(); $book->addChapter("Log", "Log.html", $content_start . $log->getLog() . "\n</pre>" . $bookEnd); if ($book->isLogging) { // Only used in case we need to debug EPub.php. $epuplog = $book->getLog(); $book->addChapter("ePubLog", "ePubLog.html", $content_start . $epuplog . "\n</pre>" . $bookEnd); } $book->finalize(); // Finalize the book, and build the archive. // This is not really a part of the EPub class, but IF you have errors and want to know about them, // they would have been written to the output buffer, preventing the book from being sent. // This behaviour is desired as the book will then most likely be corrupt. // However you might want to dump the output to a log, this example section can do that: /*