finalize() public method

Once finalized, the book is locked for further additions.
public finalize ( ) : boolean
return boolean $success
 /**
  * @param null|string $filename
  * @return void
  */
 public function save($filename = null)
 {
     if (is_null($filename)) {
         $filename = time() . Random::getRandStr(32);
     }
     $this->filename = $filename;
     $this->epub->finalize();
     $this->epub->saveBook($filename, storage_path($this->getPath()));
 }
Beispiel #2
0
$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 hierarchy 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:
/*
if (ob_get_contents() !== false && ob_get_contents() != '') {
    $f = fopen ('./log.txt', 'a') or die("Unable to open log.txt.");
    fwrite($f, "\r\n" . date("D, d M Y H:i:s T") . ": Error in " . __FILE__ . ": \r\n");
    fwrite($f, ob_get_contents() . "\r\n");
    fclose($f);
}
*/
// Save book as a file relative to your script (for local ePub generation)
// Notice that the extension .epub will be added by the script.