PHP Class PHPePub\Core\EPub

Please note, once finalized a book can no longer have chapters of data added or changed. License: GNU LGPL 2.1. Thanks to: Adam Schmalhofer and Kirstyn Fox for invaluable input and for "nudging" me in the right direction :)
Datei anzeigen Open project: grandt/phpepub Class Usage Examples

Public Properties

Property Type Description
$encodeHTML
$isGifImagesEnabled getImage will convert these if it can, unless this is set to TRUE.
$isLogging
$isReferencesAddedToToc
$maxImageHeight
$maxImageWidth
$pluginDir
$referencesOrder If this list is overwritten it MUST contain at least "text" as an element.
$splitDefaultSize
$viewportMap

Public Methods

Method Description
DANGER_getNcx ( ) : null | PHPePub\Core\Structure\Ncx The Ncx data isn't generated before the ePub is finalized.
DANGER_getOpf ( ) : null | Opf The Opf data isn't generated before the ePub is finalized.
DANGER_getZip ( ) : null | Zip The Zip file isn't completed before the ePub is finalized, however files added ARE packed and written to it immediately, and their contents can't be altered.
__construct ( string $bookVersion = EPub::BOOK_VERSION_EPUB2, string $languageCode = 'en', string $writingDirection = EPub::DIRECTION_LEFT_TO_RIGHT ) Class constructor.
__destruct ( ) : void Class destructor
addCSSFile ( string $fileName, string $fileId, string $fileData, integer $externalReferences = EPub::EXTERNAL_REF_IGNORE, string $baseDir = "" ) : boolean Add a CSS file to the book.
addChapter ( string $chapterName, string $fileName, string $chapterData = null, boolean $autoSplit = false, integer $externalReferences = EPub::EXTERNAL_REF_IGNORE, string $baseDir = "" ) : mixed Add a chapter to the book, as a chapter should not exceed 250kB, you can parse an array with multiple parts as $chapterData.
addCustomMetaProperty ( string $name, string $content ) Add a Meta property value to the metadata
addCustomMetaValue ( PHPePub\Core\Structure\OPF\MetaValue $value ) Add a custom meta data value to the OPF metadata.
addCustomMetadata ( string $name, string $content ) Add custom metadata to the book.
addCustomNamespace ( string $nsName, string $nsURI )
addCustomPrefix ( string $name, string $URI ) Add a prefix declaration to the OPF file.
addDublinCoreMetadata ( string $dublinCoreConstant, string $value ) Add DublinCore metadata to the book
addEPub3TOC ( string $fileName, string $tocData ) : boolean
addFile ( string $fileName, string $fileId, string $fileData, string $mimetype ) : boolean Add dynamically generated data as a file to the book.
addFileToMETAINF ( string $fileName, string $fileData ) : boolean Add a file to the META-INF directory.
addLargeFile ( string $fileName, string $fileId, string $filePath, string $mimetype ) : boolean Add a large file directly from the filestystem to the book.
addReferencePage ( string $pageName, string $fileName, string $pageData, string $reference, integer $externalReferences = EPub::EXTERNAL_REF_IGNORE, string $baseDir = "" ) : boolean Reference pages is usually one or two pages for items such as Table of Contents, reference lists, Author notes or Acknowledgements.
backLevel ( ) Step back one chapter level.
buildEPub3TOC ( string $cssFileName = null, string $title = "Table of Contents" ) : string
buildTOC ( string $cssFileName = null, string $tocCSSClass = "toc", string $title = "Table of Contents", boolean $addReferences = true, boolean $addToIndex = false, string $tocFileName = "TOC.xhtml" ) : boolean Build the Table of Contents. This is not strictly necessary, as most eReaders will build it from the navigation structure in the .ncx file.
extractIdAttributes ( string $partName, string $chapterData )
finalize ( ) : boolean Check for mandatory parameters and finalize the e-book.
findIdAttributes ( string $chapterData ) : array find all id attributes in the html document.
getAuthor ( ) : string Get Book author.
getBook ( ) : string Return the finalized book.
getBookSize ( ) : string Return the finalized book size.
getChapterCount ( ) : number Get Book Chapter count.
getCoverage ( ) : string Get Book coverage.
getCurrentLevel ( ) : integer Get current level count.
getDate ( ) : string Get Book date.
getDescription ( ) : string Get Book description.
getFileList ( ) : array Retrieve an array of file names currently added to the book.
getGenerator ( ) : string Get the book relation.
getIdentifier ( ) : string Get Book identifier.
getIdentifierType ( ) : string Get Book identifierType.
getLanguage ( ) : string Get Book language.
getLog ( ) : string
getPublisherName ( ) : string Get Book publisherName.
getPublisherURL ( ) : string Get Book publisherURL.
getRelation ( ) : string Get the book relation.
getRights ( ) : string Get Book rights.
getSourceURL ( ) : string Get Book sourceURL.
getSplitSize ( ) : integer Get the chapter target size.
getTitle ( ) : string Get Book title.
getViewportMetaLine ( ) : string Generate the viewport meta line if the viewport is set.
isEPubVersion2 ( ) : boolean
isFinalized ( ) : boolean Get Book status.
rootLevel ( ) Step back to the root level.
saveBook ( string $fileName, string $baseDir = '.' ) : string Save the ePub file to local disk.
sendBook ( string $fileName ) : string | boolean Send the book as a zip download
setAuthor ( string $author, string $authorSortKey ) : boolean Book author or creator, optional.
setBookRoot ( string $bookRoot ) The bookRoot is the root directory inside the ePub book, defaults to "OEBPS/"
setCoverImage ( string $fileName, string $imageData = null, string $mimetype = null ) : boolean Add a cover image to the book.
setCoverage ( string $coverage ) : boolean Coverage, optional.
setCurrentLevel ( integer $newLevel ) Step back to the given level.
setDangermode ( boolean $dangermode ) Set or clear "Dangermode"
setDate ( integer $timestamp ) : boolean Release date, optional. If left blank, the time of the finalization will be used.
setDescription ( string $description ) : boolean Book description, optional.
setGenerator ( string $generator ) Set book Generator.
setIdentifier ( string $identifier, string $identifierType ) : boolean Unique book identifier, mandatory.
setLanguage ( string $language ) : boolean Book language, mandatory
setPublisher ( string $publisherName, string $publisherURL ) : boolean Publisher Information, optional.
setReferencesTitle ( string $referencesTitle = "Guide", string $referencesId = "", string $referencesClass = "references" ) : boolean Set the references title for the ePub 3 landmarks section
setRelation ( string $relation ) Set book Relation.
setRights ( string $rightsText ) : boolean Book (copy)rights, optional.
setShortDateFormat ( ) : boolean Set ePub date formate to the short yyyy-mm-dd form, for compliance with a bug in EpubCheck, prior to its version 1.1.
setSourceURL ( string $sourceURL ) : boolean Book source URL, optional.
setSplitSize ( integer $size ) : void Set default chapter target size.
setSubject ( string $subject ) Add book Subject.
setTitle ( string $title ) : boolean Book title, mandatory.
setViewport ( integer | string $width = null, integer $height = null ) Viewport is used for fixed-layout books, specifically ePub 3 books using the Rendition metadata.
setisReferencesAddedToToc ( boolean $isReferencesAddedToToc = true ) : boolean Set the references title for the ePub 3 landmarks section
subLevel ( string $navTitle = null, string $navId = null, string $navClass = null, boolean $isNavHidden = false, string $writingDirection = null ) : boolean | NavPoint Add one chapter level.

Protected Methods

Method Description
processCSSExternalReferences ( &$cssFile, integer $externalReferences = EPub::EXTERNAL_REF_ADD, string $baseDir = "", string $cssDir = "" ) : boolean Process images referenced from an CSS file to the book.
processChapterExternalReferences ( &$doc, integer $externalReferences = EPub::EXTERNAL_REF_ADD, string $baseDir = "", string $htmlDir = "" ) : boolean Process external references from a HTML to the book. The chapter itself is not stored.
processChapterImages ( &$xmlDoc, integer $externalReferences = EPub::EXTERNAL_REF_ADD, string $baseDir = "", string $htmlDir = "", string $backPath = "" ) : boolean Process img tags in a DOMDocument.
processChapterLinks ( &$xmlDoc, integer $externalReferences = EPub::EXTERNAL_REF_ADD, string $baseDir = "", string $htmlDir = "", string $backPath = "" ) : boolean Process link tags in a DOMDocument. Linked files will be loaded into the archive, and the link src will be rewritten to point to that location.
processChapterSources ( &$xmlDoc, integer $externalReferences = EPub::EXTERNAL_REF_ADD, string $baseDir = "", string $htmlDir = "", string $backPath = "" ) : boolean Process source tags in a DOMDocument.
processChapterStyles ( &$xmlDoc, integer $externalReferences = EPub::EXTERNAL_REF_ADD, string $baseDir = "", string $htmlDir = "" ) : boolean Process style tags in a DOMDocument. Styles will be passed as CSS files and reinserted into the document.
resolveImage ( string $source, &$internalPath, &$internalSrc, &$isSourceExternal, string $baseDir = "", string $htmlDir = "" ) : boolean Resolve an image src and determine it's target location and add it to the book.
resolveMedia ( string $source, string &$internalPath, string &$internalSrc, string &$isSourceExternal, string $baseDir = "", string $htmlDir = "" ) : boolean Resolve a media src and determine it's target location and add it to the book.

Private Methods

Method Description
finalizeTOC ( ) : boolean Finalize and build final ePub structures.
initialize ( ) initialize defaults.
setUp ( )
wrapChapter ( $content ) : string Wrap ChapterContent with Head and Footer

Method Details

DANGER_getNcx() public method

The Ncx data isn't generated before the ePub is finalized.
public DANGER_getNcx ( ) : null | PHPePub\Core\Structure\Ncx
return null | PHPePub\Core\Structure\Ncx The Ncx Navigation class

DANGER_getOpf() public method

The Opf data isn't generated before the ePub is finalized.
public DANGER_getOpf ( ) : null | Opf
return null | PHPePub\Core\Structure\Opf the Opf structure class.

DANGER_getZip() public method

See the phpzip/phpzip composer package for usage.
public DANGER_getZip ( ) : null | Zip
return null | PHPZip\Zip\File\Zip The actual zip file.

__construct() public method

Class constructor.
public __construct ( string $bookVersion = EPub::BOOK_VERSION_EPUB2, string $languageCode = 'en', string $writingDirection = EPub::DIRECTION_LEFT_TO_RIGHT )
$bookVersion string
$languageCode string
$writingDirection string

__destruct() public method

Class destructor
public __destruct ( ) : void
return void

addCSSFile() public method

Add a CSS file to the book.
public addCSSFile ( string $fileName, string $fileId, string $fileData, integer $externalReferences = EPub::EXTERNAL_REF_IGNORE, string $baseDir = "" ) : boolean
$fileName string Filename to use for the CSS file, must be unique for the book.
$fileId string Unique identifier for the file.
$fileData string CSS data
$externalReferences integer How to handle external references, EPub::EXTERNAL_REF_IGNORE, EPub::EXTERNAL_REF_ADD or EPub::EXTERNAL_REF_REMOVE_IMAGES? See documentation for processCSSExternalReferences for explanation. Default is EPub::EXTERNAL_REF_IGNORE.
$baseDir string Default is "", meaning it is pointing to the document root. NOT used if $externalReferences is set to EPub::EXTERNAL_REF_IGNORE.
return boolean $success

addChapter() public method

These will still only show up as a single chapter in the book TOC.
public addChapter ( string $chapterName, string $fileName, string $chapterData = null, boolean $autoSplit = false, integer $externalReferences = EPub::EXTERNAL_REF_IGNORE, string $baseDir = "" ) : mixed
$chapterName string Name of the chapter, will be use din the TOC
$fileName string Filename to use for the chapter, must be unique for the book.
$chapterData string Chapter text in XHTML or array $chapterData valid XHTML data for the chapter. File should NOT exceed 250kB.
$autoSplit boolean Should the chapter be split if it exceeds the default split size? Default=FALSE, only used if $chapterData is a string.
$externalReferences integer How to handle external references, EPub::EXTERNAL_REF_IGNORE, EPub::EXTERNAL_REF_ADD or EPub::EXTERNAL_REF_REMOVE_IMAGES? See documentation for processChapterExternalReferences for explanation. Default is EPub::EXTERNAL_REF_IGNORE.
$baseDir string Default is "", meaning it is pointing to the document root. NOT used if $externalReferences is set to EPub::EXTERNAL_REF_IGNORE.
return mixed $success FALSE if the addition failed, else the new NavPoint.

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

addCustomMetaValue() public method

Remember to add the namespace as well. Metadata comes in the form: value
public addCustomMetaValue ( PHPePub\Core\Structure\OPF\MetaValue $value )
$value PHPePub\Core\Structure\OPF\MetaValue

addCustomMetadata() public method

It is up to the builder to make sure there are no collisions. Metadata are just key value pairs.
public addCustomMetadata ( string $name, string $content )
$name string
$content string

addCustomNamespace() public method

public addCustomNamespace ( string $nsName, string $nsURI )
$nsName string
$nsURI string

addCustomPrefix() public method

Only supported on EPUB3 books.
public addCustomPrefix ( string $name, string $URI )
$name string
$URI string

addDublinCoreMetadata() public method

Use the DublinCore constants included in EPub, ie DublinCore::DATE
public addDublinCoreMetadata ( string $dublinCoreConstant, string $value )
$dublinCoreConstant string name
$value string

addEPub3TOC() public method

public addEPub3TOC ( string $fileName, string $tocData ) : boolean
$fileName string
$tocData string
return boolean

addFile() public method

Add dynamically generated data as a file to the book.
public addFile ( string $fileName, string $fileId, string $fileData, string $mimetype ) : boolean
$fileName string Filename to use for the file, must be unique for the book.
$fileId string Unique identifier for the file.
$fileData string File data
$mimetype string file mime type
return boolean $success

addFileToMETAINF() public method

Bloody Apple and their bloody proprietary ways of doing things.
public addFileToMETAINF ( string $fileName, string $fileData ) : boolean
$fileName string Filename to use for the file, must be unique for the book.
$fileData string File data
return boolean $success

addLargeFile() public method

Add a large file directly from the filestystem to the book.
public addLargeFile ( string $fileName, string $fileId, string $filePath, string $mimetype ) : boolean
$fileName string Filename to use for the file, must be unique for the book.
$fileId string Unique identifier for the file.
$filePath string File path
$mimetype string file mime type
return boolean $success

addReferencePage() public method

These do not show up in the regular navigation list. As they are supposed to be short.
public addReferencePage ( string $pageName, string $fileName, string $pageData, string $reference, integer $externalReferences = EPub::EXTERNAL_REF_IGNORE, string $baseDir = "" ) : boolean
$pageName string Name of the chapter, will be use din the TOC
$fileName string Filename to use for the chapter, must be unique for the book.
$pageData string Page content in XHTML. File should NOT exceed 250kB.
$reference string Reference key
$externalReferences integer How to handle external references. See documentation for processChapterExternalReferences for explanation. Default is EPub::EXTERNAL_REF_IGNORE.
$baseDir string Default is "", meaning it is pointing to the document root. NOT used if $externalReferences is set to EPub::EXTERNAL_REF_IGNORE.
return boolean $success

backLevel() public method

Subsequent chapters will be added to this chapters parent level.
public backLevel ( )

buildEPub3TOC() public method

public buildEPub3TOC ( string $cssFileName = null, string $title = "Table of Contents" ) : string
$cssFileName string
$title string
return string

buildTOC() public method

Build the Table of Contents. This is not strictly necessary, as most eReaders will build it from the navigation structure in the .ncx file.
public buildTOC ( string $cssFileName = null, string $tocCSSClass = "toc", string $title = "Table of Contents", boolean $addReferences = true, boolean $addToIndex = false, string $tocFileName = "TOC.xhtml" ) : boolean
$cssFileName string Include a link to this css file in the TOC html.
$tocCSSClass string The TOC is a
, if you need special formatting, you can add a css class for that div. Default is "toc".
$title string Title of the Table of contents. Default is "Table of Contents". Use this for ie. languages other than English.
$addReferences boolean include reference pages in the TOC, using the $referencesOrder array to determine the order of the pages in the TOC. Default is TRUE.
$addToIndex boolean Add the TOC to the NCX index at the current leve/position. Default is FALSE
$tocFileName string Change the default name of the TOC file. The default is "TOC.xhtml"
return boolean

extractIdAttributes() public method

public extractIdAttributes ( string $partName, string $chapterData )
$partName string
$chapterData string

finalize() public method

Once finalized, the book is locked for further additions.
public finalize ( ) : boolean
return boolean $success

findIdAttributes() public method

find all id attributes in the html document.
public findIdAttributes ( string $chapterData ) : array
$chapterData string
return array

getAuthor() public method

Get Book author.
public getAuthor ( ) : string
return string $author

getBook() public method

Return the finalized book.
public getBook ( ) : string
return string with the book in binary form.

getBookSize() public method

Return the finalized book size.
public getBookSize ( ) : string
return string

getChapterCount() public method

Get Book Chapter count.
public getChapterCount ( ) : number
return number of chapters

getCoverage() public method

Get Book coverage.
public getCoverage ( ) : string
return string $coverage

getCurrentLevel() public method

The indentation of the current structure point.
public getCurrentLevel ( ) : integer
return integer current level count;

getDate() public method

Get Book date.
public getDate ( ) : string
return string $date

getDescription() public method

Get Book description.
public getDescription ( ) : string
return string $description

getFileList() public method

$key is the filename used in the book $value is the original filename, will be the same as $key for most entries
public getFileList ( ) : array
return array file list

getGenerator() public method

Get the book relation.
public getGenerator ( ) : string
return string The generator identity string.

getIdentifier() public method

Get Book identifier.
public getIdentifier ( ) : string
return string $identifier

getIdentifierType() public method

Get Book identifierType.
public getIdentifierType ( ) : string
return string $identifierType

getLanguage() public method

Get Book language.
public getLanguage ( ) : string
return string $language

getLog() public method

public getLog ( ) : string
return string

getPublisherName() public method

Get Book publisherName.
public getPublisherName ( ) : string
return string $publisherName

getPublisherURL() public method

Get Book publisherURL.
public getPublisherURL ( ) : string
return string $publisherURL

getRelation() public method

Get the book relation.
public getRelation ( ) : string
return string The relation.

getRights() public method

Get Book rights.
public getRights ( ) : string
return string $rights

getSourceURL() public method

Get Book sourceURL.
public getSourceURL ( ) : string
return string $sourceURL

getSplitSize() public method

Get the chapter target size.
public getSplitSize ( ) : integer
return integer $size

getTitle() public method

Get Book title.
public getTitle ( ) : string
return string $title

getViewportMetaLine() public method

Generate the viewport meta line if the viewport is set.
public getViewportMetaLine ( ) : string
return string the meta data line, or an empty string if no viewport is defined.

isEPubVersion2() public method

public isEPubVersion2 ( ) : boolean
return boolean

isFinalized() public method

Get Book status.
public isFinalized ( ) : boolean
return boolean

processCSSExternalReferences() protected method

$externalReferences determins how the function will handle external references.
protected processCSSExternalReferences ( &$cssFile, integer $externalReferences = EPub::EXTERNAL_REF_ADD, string $baseDir = "", string $cssDir = "" ) : boolean
$externalReferences integer How to handle external references, EPub::EXTERNAL_REF_IGNORE, EPub::EXTERNAL_REF_ADD or EPub::EXTERNAL_REF_REMOVE_IMAGES? Default is EPub::EXTERNAL_REF_ADD.
$baseDir string Default is "", meaning it is pointing to the document root.
$cssDir string The of the CSS file's directory from the root of the archive.
return boolean FALSE if unsuccessful (book is finalized or $externalReferences == EXTERNAL_REF_IGNORE).

processChapterExternalReferences() protected method

the HTML is scanned for <link..., <style..., and <img tags. Embedded CSS styles and links will also be processed. Script tags are not processed, as scripting should be avoided in e-books. EPub keeps track of added files, and duplicate files referenced across multiple chapters, are only added once. If the $doc is a string, it is assumed to be the content of an HTML file, else is it assumes to be a DOMDocument. Basedir is the root dir the HTML is supposed to "live" in, used to resolve relative references such as <img src="../images/image.png"/> $externalReferences determines how the function will handle external references.
protected processChapterExternalReferences ( &$doc, integer $externalReferences = EPub::EXTERNAL_REF_ADD, string $baseDir = "", string $htmlDir = "" ) : boolean
$externalReferences integer How to handle external references, EPub::EXTERNAL_REF_IGNORE, EPub::EXTERNAL_REF_ADD or EPub::EXTERNAL_REF_REMOVE_IMAGES? Default is EPub::EXTERNAL_REF_ADD.
$baseDir string Default is "", meaning it is pointing to the document root.
$htmlDir string The path to the parent HTML file's directory from the root of the archive.
return boolean false if unsuccessful (book is finalized or $externalReferences == EXTERNAL_REF_IGNORE).

processChapterImages() protected method

$externalReferences will determine what will happen to these images, and the img src will be rewritten accordingly.
protected processChapterImages ( &$xmlDoc, integer $externalReferences = EPub::EXTERNAL_REF_ADD, string $baseDir = "", string $htmlDir = "", string $backPath = "" ) : boolean
$externalReferences integer How to handle external references, EPub::EXTERNAL_REF_IGNORE, EPub::EXTERNAL_REF_ADD or EPub::EXTERNAL_REF_REMOVE_IMAGES? Default is EPub::EXTERNAL_REF_ADD.
$baseDir string Default is "", meaning it is pointing to the document root.
$htmlDir string The path to the parent HTML file's directory from the root of the archive.
$backPath string The path to get back to the root of the archive from $htmlDir.
return boolean FALSE if uncuccessful (book is finalized or $externalReferences == EXTERNAL_REF_IGNORE).

processChapterSources() protected method

$externalReferences will determine what will happen to these images, and the img src will be rewritten accordingly.
protected processChapterSources ( &$xmlDoc, integer $externalReferences = EPub::EXTERNAL_REF_ADD, string $baseDir = "", string $htmlDir = "", string $backPath = "" ) : boolean
$externalReferences integer How to handle external references, EPub::EXTERNAL_REF_IGNORE, EPub::EXTERNAL_REF_ADD or EPub::EXTERNAL_REF_REMOVE_IMAGES? Default is EPub::EXTERNAL_REF_ADD.
$baseDir string Default is "", meaning it is pointing to the document root.
$htmlDir string The path to the parent HTML file's directory from the root of the archive.
$backPath string The path to get back to the root of the archive from $htmlDir.
return boolean FALSE if uncuccessful (book is finalized or $externalReferences == EXTERNAL_REF_IGNORE).

processChapterStyles() protected method

Process style tags in a DOMDocument. Styles will be passed as CSS files and reinserted into the document.
protected processChapterStyles ( &$xmlDoc, integer $externalReferences = EPub::EXTERNAL_REF_ADD, string $baseDir = "", string $htmlDir = "" ) : boolean
$externalReferences integer How to handle external references, EPub::EXTERNAL_REF_IGNORE, EPub::EXTERNAL_REF_ADD or EPub::EXTERNAL_REF_REMOVE_IMAGES? Default is EPub::EXTERNAL_REF_ADD.
$baseDir string Default is "", meaning it is pointing to the document root.
$htmlDir string The path to the parent HTML file's directory from the root of the archive.
return boolean FALSE if uncuccessful (book is finalized or $externalReferences == EXTERNAL_REF_IGNORE).

resolveImage() protected method

Resolve an image src and determine it's target location and add it to the book.
protected resolveImage ( string $source, &$internalPath, &$internalSrc, &$isSourceExternal, string $baseDir = "", string $htmlDir = "" ) : boolean
$source string Image Source link.
$baseDir string Default is "", meaning it is pointing to the document root.
$htmlDir string The path to the parent HTML file's directory from the root of the archive.
return boolean

resolveMedia() protected method

Resolve a media src and determine it's target location and add it to the book.
protected resolveMedia ( string $source, string &$internalPath, string &$internalSrc, string &$isSourceExternal, string $baseDir = "", string $htmlDir = "" ) : boolean
$source string Source link.
$internalPath string (referenced) Return value, will be set to the target path and name in the book.
$internalSrc string (referenced) Return value, will be set to the target name in the book.
$isSourceExternal string (referenced) Return value, will be set to TRUE if the image originated from a full URL.
$baseDir string Default is "", meaning it is pointing to the document root.
$htmlDir string The path to the parent HTML file's directory from the root of the archive.
return boolean

rootLevel() public method

Subsequent chapters will be added to the rooot NavMap.
public rootLevel ( )

saveBook() public method

Save the ePub file to local disk.
public saveBook ( string $fileName, string $baseDir = '.' ) : string
$fileName string
$baseDir string If empty baseDir is absolute to server path, if omitted it's relative to script path
return string The sent file name if successful, FALSE if it failed.

sendBook() public method

Sending will fail if the output buffer is in use. You can override this limit by calling setIgnoreEmptyBuffer(TRUE), though the function will still fail if that buffer is not empty.
public sendBook ( string $fileName ) : string | boolean
$fileName string The name of the book without the .epub at the end.
return string | boolean The sent file name if successful, FALSE if it failed.

setAuthor() public method

The $authorSortKey is basically how the name is to be sorted, usually it's "Lastname, First names" where the $author is the straight "Firstnames Lastname" An entity primarily responsible for making the resource. Examples of a Creator include a person, an organization, or a service. Typically, the name of a Creator should be used to indicate the entity. Used for the dc:creator metadata parameter in the OPF file and the docAuthor attribure in the NCX file. The sort key is used for the opf:file-as attribute in dc:creator.
public setAuthor ( string $author, string $authorSortKey ) : boolean
$author string
$authorSortKey string
return boolean $success

setBookRoot() public method

The bookRoot is the root directory inside the ePub book, defaults to "OEBPS/"
public setBookRoot ( string $bookRoot )
$bookRoot string

setCoverImage() public method

If the $imageData is not set, the function assumes the $fileName is the path to the image file. The styling and structure of the generated XHTML is heavily inspired by the XHTML generated by Calibre.
public setCoverImage ( string $fileName, string $imageData = null, string $mimetype = null ) : boolean
$fileName string Filename to use for the image, must be unique for the book.
$imageData string Binary image data
$mimetype string Image mimetype, such as "image/jpeg" or "image/png".
return boolean $success

setCoverage() public method

The spatial or temporal topic of the resource, the spatial applicability of the resource, or the jurisdiction under which the resource is relevant. Spatial topic and spatial applicability may be a named place or a location specified by its geographic coordinates. Temporal topic may be a named period, date, or date range. A jurisdiction may be a named administrative entity or a geographic place to which the resource applies. Recommended best practice is to use a controlled vocabulary such as the Thesaurus of Geographic Names [TGN]. Where appropriate, named places or time periods can be used in preference to numeric identifiers such as sets of coordinates or date ranges. Used for the dc:coverage metadata parameter in the OPF file Same as ->addDublinCoreMetadata(DublinCore::COVERAGE, $coverage);
public setCoverage ( string $coverage ) : boolean
$coverage string
return boolean $success

setCurrentLevel() public method

Useful for returning to a previous level from deep within the structure. Values below 2 will have the same effect as rootLevel()
public setCurrentLevel ( integer $newLevel )
$newLevel integer

setDangermode() public method

Dangermode allows the user to access the structure of the ePub directly, potentially leading to defective files.
public setDangermode ( boolean $dangermode )
$dangermode boolean

setDate() public method

A point or period of time associated with an event in the lifecycle of the resource. Date may be used to express temporal information at any level of granularity. Recommended best practice is to use an encoding scheme, such as the W3CDTF profile of ISO 8601 [W3CDTF]. Used for the dc:date metadata parameter in the OPF file
public setDate ( integer $timestamp ) : boolean
$timestamp integer
return boolean $success

setDescription() public method

An account of the resource. Description may include but is not limited to: an abstract, a table of contents, a graphical representation, or a free-text account of the resource. Used for the dc:source metadata parameter in the OPF file
public setDescription ( string $description ) : boolean
$description string
return boolean $success

setGenerator() public method

The generator is a meta tag added to the ncx file, it is not visible from within the book, but is a kind of electronic watermark.
public setGenerator ( string $generator )
$generator string

setIdentifier() public method

Use the URI, or ISBN if available. An unambiguous reference to the resource within a given context. Recommended best practice is to identify the resource by means of a string conforming to a formal identification system. Used for the dc:identifier metadata parameter in the OPF file, as well as dtb:uid in the NCX file. Identifier type should only be: EPub::IDENTIFIER_URI EPub::IDENTIFIER_ISBN EPub::IDENTIFIER_UUID
public setIdentifier ( string $identifier, string $identifierType ) : boolean
$identifier string
$identifierType string
return boolean $success

setLanguage() public method

Use the RFC3066 Language codes, such as "en", "da", "fr" etc. Defaults to "en". Used for the dc:language metadata parameter in the OPF file.
public setLanguage ( string $language ) : boolean
$language string
return boolean $success

setPublisher() public method

An entity responsible for making the resource available. Examples of a Publisher include a person, an organization, or a service. Typically, the name of a Publisher should be used to indicate the entity. Used for the dc:publisher and dc:relation metadata parameters in the OPF file.
public setPublisher ( string $publisherName, string $publisherURL ) : boolean
$publisherName string
$publisherURL string
return boolean $success

setReferencesTitle() public method

Set the references title for the ePub 3 landmarks section
public setReferencesTitle ( string $referencesTitle = "Guide", string $referencesId = "", string $referencesClass = "references" ) : boolean
$referencesTitle string
$referencesId string
$referencesClass string
return boolean

setRelation() public method

A related resource. Recommended best practice is to identify the related resource by means of a string conforming to a formal identification system.
public setRelation ( string $relation )
$relation string

setRights() public method

Information about rights held in and over the resource. Typically, rights information includes a statement about various property rights associated with the resource, including intellectual property rights. Used for the dc:rights metadata parameter in the OPF file
public setRights ( string $rightsText ) : boolean
$rightsText string
return boolean $success

setShortDateFormat() public method

The latest version of ePubCheck can be obtained here: http://code.google.com/p/epubcheck/
public setShortDateFormat ( ) : boolean
return boolean $success

setSourceURL() public method

A related resource from which the described resource is derived. The described resource may be derived from the related resource in whole or in part. Recommended best practice is to identify the related resource by means of a string conforming to a formal identification system. Used for the dc:source metadata parameter in the OPF file
public setSourceURL ( string $sourceURL ) : boolean
$sourceURL string
return boolean $success

setSplitSize() public method

Default is 250000 bytes, and minimum is 10240 bytes.
public setSplitSize ( integer $size ) : void
$size integer segment size in bytes
return void

setSubject() public method

The topic of the resource. Typically, the subject will be represented using keywords, key phrases, or classification codes. Recommended best practice is to use a controlled vocabulary. To describe the spatial or temporal topic of the resource, use the Coverage element.
public setSubject ( string $subject )
$subject string

setTitle() public method

Used for the dc:title metadata parameter in the OPF file as well as the DocTitle attribute in the NCX file.
public setTitle ( string $title ) : boolean
$title string
return boolean $success

setViewport() public method

Calling this function without arguments clears the viewport. The predefined viewports can be accessed with $this->viewportMap
public setViewport ( integer | string $width = null, integer $height = null )
$width integer | string integer for the width, or a string referencing an entry in the $viewportMap.
$height integer

setisReferencesAddedToToc() public method

Set the references title for the ePub 3 landmarks section
public setisReferencesAddedToToc ( boolean $isReferencesAddedToToc = true ) : boolean
$isReferencesAddedToToc boolean
return boolean

subLevel() public method

Subsequent chapters will be added to this level.
public subLevel ( string $navTitle = null, string $navId = null, string $navClass = null, boolean $isNavHidden = false, string $writingDirection = null ) : boolean | NavPoint
$navTitle string
$navId string
$navClass string
$isNavHidden boolean
$writingDirection string
return boolean | PHPePub\Core\Structure\NCX\NavPoint The new NavPoint for that level.

Property Details

$encodeHTML public_oe property

public $encodeHTML

$isGifImagesEnabled public_oe property

getImage will convert these if it can, unless this is set to TRUE.
public $isGifImagesEnabled

$isLogging public_oe property

public $isLogging

$isReferencesAddedToToc public_oe property

public $isReferencesAddedToToc

$maxImageHeight public_oe property

public $maxImageHeight

$maxImageWidth public_oe property

public $maxImageWidth

$pluginDir public_oe property

public $pluginDir

$referencesOrder public_oe property

If this list is overwritten it MUST contain at least "text" as an element.
public $referencesOrder

$splitDefaultSize public_oe property

public $splitDefaultSize

$viewportMap public_oe property

public $viewportMap