addCustomMetaProperty() public method

Properties in the metadata looks like: value Remember to add the namespace as well.
public addCustomMetaProperty ( string $name, string $content )
$name string property name, including the namespace declaration, ie. "dcterms:modified"
$content string
Beispiel #1
0
 /**
  * @param EPub   $book
  * @param string $value "landscape", "portrait" or "auto"
  */
 public static function setSpread($book, $value)
 {
     if (!$book->isEPubVersion2() && $value === self::SPREAD_NONE || $value === self::SPREAD_LANDSCAPE || $value === self::SPREAD_PORTRAIT || $value === self::SPREAD_BOTH || $value === self::SPREAD_AUTO) {
         $book->addCustomMetaProperty(self::RENDITION_SPREAD, $value);
     }
 }
Beispiel #2
0
$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
//  pixels, adding mega-pixel images is a waste of place and spends bandwidth. setCoverImage can resize the image.
//  When using this method, the given image path must be the absolute path from the servers Document root.
Beispiel #3
0
 /**
  * @param EPub $book
  * @param bool $value
  */
 public static function setBinding($book, $value)
 {
     if (!$book->isEPubVersion2()) {
         $book->addCustomMetaProperty(self::EPUB3_BINDING, Boolean::getBoolean($value));
     }
 }
Beispiel #4
0
 /**
  * @param EPub $book
  * @param bool $value
  */
 function setEPub3IBooksBinding($book, $value)
 {
     $book->addCustomMetaProperty(Properties::EPUB3_BINDING, $this->getIBookBoolean($value));
 }