addCustomPrefix() public method

Only supported on EPUB3 books.
public addCustomPrefix ( string $name, string $URI )
$name string
$URI string
示例#1
0
 /**
  * Add iBooks prefix to the ePub book
  *
  * @param EPub $book
  */
 public static function addPrefix($book)
 {
     if (!$book->isEPubVersion2()) {
         $book->addCustomPrefix(self::RENDITION_PREFIX_NAME, self::RENDITION_PREFIX_URI);
     }
 }
示例#2
0
$book->setPublisher("John and Jane Doe Publications", "http://JohnJaneDoePublications.com/");
// I hope this is a non existent address :)
$book->setDate(time());
// Strictly not needed as the book date defaults to time().
$book->setRights("Copyright and licence information specific for the book.");
// As this is generated, this _could_ contain the name or licence information of the user who purchased the book, if needed. If this is used that way, the identifier must also be made unique for the book.
$book->setSourceURL("http://JohnJaneDoePublications.com/books/TestBookEPub3.html");
$book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, "PHP");
$book->setSubject("Test book");
$book->setSubject("keywords");
$book->setSubject("Chapter levels");
// Insert custom meta data to the book, in this case, Calibre series index information.
$book->addCustomMetadata("calibre:series", "PHPePub Test books");
$book->addCustomMetadata("calibre:series_index", "3");
// FIXED-LAYOUT METADATA (ONLY AVAILABLE IN EPUB3)
$book->addCustomPrefix("rendition", StaticData::$prefixNamespaces["rendition"]);
$book->addCustomPrefix(iBooks::EPUB3_IBOOK_PREFIX_NAME, iBooks::EPUB3_IBOOK_PREFIX_URI);
$book->addCustomMetaProperty("rendition:layout", "pre-paginated");
$book->addCustomMetaProperty("rendition:orientation", "auto");
$book->addCustomMetaProperty("rendition:spread", "auto");
$book->addCustomMetaProperty("ibooks:iphone-orientation-lock", "portrait-only");
$book->addCustomMetaProperty("ibooks:specified-fonts", "true");
$book->addCustomMetaProperty("ibooks:fixed-layout", "true");
$log->logLine("Set up parameters");
$cssData = "body {\n  margin-left: .5em;\n  margin-right: .5em;\n  text-align: justify;\n}\n\np {\n  font-family: serif;\n  font-size: 10pt;\n  text-align: justify;\n  text-indent: 1em;\n  margin-top: 0px;\n  margin-bottom: 1ex;\n}\n\nh1, h2 {\n  font-family: sans-serif;\n  font-style: italic;\n  text-align: center;\n  background-color: #6b879c;\n  color: white;\n  width: 100%;\n}\n\nh1 {\n    margin-bottom: 2px;\n}\n\nh2 {\n    margin-top: -2px;\n    margin-bottom: 2px;\n}\n";
$log->logLine("Add css");
$book->addCSSFile("styles.css", "css1", $cssData);
// This test requires you have an image, change "demo/cover-image.jpg" to match your location.
$log->logLine("Add Cover Image");
$book->setCoverImage("Cover.jpg", file_get_contents("demo/cover-image.jpg"), "image/jpeg");
// A better way is to let EPub handle the image itself, as it may need resizing. Most e-books are only about 600x800
示例#3
0
$book->setPublisher("John and Jane Doe Publications", "http://JohnJaneDoePublications.com/");
// I hope this is a non existent address :)
$book->setDate(time());
// Strictly not needed as the book date defaults to time().
$book->setRights("Copyright and licence information specific for the book.");
// As this is generated, this _could_ contain the name or licence information of the user who purchased the book, if needed. If this is used that way, the identifier must also be made unique for the book.
$book->setSourceURL("http://JohnJaneDoePublications.com/books/TestBookEPub3.html");
$book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, "PHP");
$book->setSubject("Test book");
$book->setSubject("keywords");
$book->setSubject("Chapter levels");
// Insert custom meta data to the book, in this case, Calibre series index information.
$book->addCustomMetadata("calibre:series", "PHPePub Test books");
$book->addCustomMetadata("calibre:series_index", "3");
// FIXED-LAYOUT METADATA (ONLY AVAILABLE IN EPUB3)
$book->addCustomPrefix("rendition", StaticData::$prefixNamespaces["rendition"]);
$book->addCustomPrefix("ibooks", StaticData::$prefixNamespaces["ibooks"]);
$book->addCustomMetaProperty("rendition:layout", "pre-paginated");
$book->addCustomMetaProperty("rendition:orientation", "auto");
$book->addCustomMetaProperty("rendition:spread", "auto");
$book->addCustomMetaProperty("ibooks:iphone-orientation-lock", "portrait-only");
$book->addCustomMetaProperty("ibooks:specified-fonts", "true");
$book->addCustomMetaProperty("ibooks:fixed-layout", "true");
$log->logLine("Set up parameters");
$cssData = "body {\n  margin-left: .5em;\n  margin-right: .5em;\n  text-align: justify;\n}\n\np {\n  font-family: serif;\n  font-size: 10pt;\n  text-align: justify;\n  text-indent: 1em;\n  margin-top: 0px;\n  margin-bottom: 1ex;\n}\n\nh1, h2 {\n  font-family: sans-serif;\n  font-style: italic;\n  text-align: center;\n  background-color: #6b879c;\n  color: white;\n  width: 100%;\n}\n\nh1 {\n    margin-bottom: 2px;\n}\n\nh2 {\n    margin-top: -2px;\n    margin-bottom: 2px;\n}\n";
$log->logLine("Add css");
$book->addCSSFile("styles.css", "css1", $cssData);
// This test requires you have an image, change "demo/cover-image.jpg" to match your location.
$log->logLine("Add Cover Image");
$book->setCoverImage("Cover.jpg", file_get_contents("demo/cover-image.jpg"), "image/jpeg");
// A better way is to let EPub handle the image itself, as it may need resizing. Most e-books are only about 600x800
示例#4
0
 /**
  * Add iBooks prefix to the ePub book
  *
  * @param EPub $book
  */
 function addEPub3IBooksPrefix($book)
 {
     $book->addCustomPrefix(self::EPUB3_IBOOK_PREFIX_NAME, self::EPUB3_IBOOK_PREFIX_URI);
 }