PHP Class Pressbooks\Modules\Export\Mpdf\Pdf

Inheritance: extends Pressbooks\Modules\Export\Export
Show file Open project: pressbooks/pressbooks Class Usage Examples

Protected Properties

Property Type Description
$bookMeta array Book Metadata
$bookTitle string Holds the title of the book being published
$exportStylePath string Fullpath to book CSS file.
$globalOptions array Global theme options, set by the user
$memoryNeeded integer mPDF uses a lot of memory, this the recommended minimum
$mpdf object MPDF Class
$numbered boolean Number the chapters
$options array mPDF theme options, set by the user

Public Methods

Method Description
__construct ( )
addBookInfo ( ) Add book information page, otherwise known as title page
addCopyright ( ) Copyright information on a separate page
addCover ( ) Add the cover for the book.
addFrontMatter ( array $contents ) Adds front matter, resets the page numbering on the first loop, romanizes the numeric style
addFrontMatterByType ( string $type, array $contents ) Add front matter of a specific/special type
addPage ( array $page, array $page_options = [], boolean $display_footer = true, boolean $display_header = true ) : boolean Add a page to the pdf
addPartsAndChapters ( $contents )
addPreContent ( array $contents ) Add all specially handled content.
addToc ( ) Add the mpdf Table of Contents.
convert ( ) : boolean Book Assembly. Create $this->outputPath
fixAnnoyingCharacters ( string $html ) : string This function prevents mPDF from completely aborting the export routine, or replacing each non-breaking space with a '?' if ignore_invalid_utf8 is true. Important to leave this in.
getBookmarkEntry ( array $page ) : string Return the PDF bookmark entry for this page should be unique, using static variable for cheap cache
getFilteredContent ( string $content ) : string Cleans up html
getFooter ( boolean $display = true, string $content = '' ) : string Return formatted footers.
getHeader ( boolean $display = true, string $content = '' ) : string Return formatted headers.
getOrderedBookContents ( ) : array Restructures \Pressbooks\Book::getBookContents() into a format more useful for direct iteration, and tracks a nesting level for Bookmark and ToC entries.
getThemeCss ( object $theme ) : string Get current child and parent theme css files. Child themes only have one parent theme, and 99% of the time this is 'Luther' or /pressbooks-book/ whose stylesheet is named 'style.css'
getTocEntry ( string $page ) : string Return the Table of Contents entry for this page.
hasDependencies ( ) : boolean Dependency check.
setCss ( ) Add all css files
validate ( ) : boolean Check the sanity of $this->outputPath

Protected Methods

Method Description
atLeastOneExport ( array $chapters ) : boolean Does array of chapters have at least one export? Recursive.
isPdf ( string $file ) : boolean Verify if file has 'application/pdf' mimeType.

Private Methods

Method Description
stripUnwantedStyles ( array $styles ) : array Helper function to omit unwanted stylesheets in the output

Method Details

__construct() public method

public __construct ( )

addBookInfo() public method

Add book information page, otherwise known as title page
public addBookInfo ( )

addCopyright() public method

Copyright information on a separate page
public addCopyright ( )

addCover() public method

Add the cover for the book.
public addCover ( )

addFrontMatter() public method

Adds front matter, resets the page numbering on the first loop, romanizes the numeric style
public addFrontMatter ( array $contents )
$contents array

addFrontMatterByType() public method

Add front matter of a specific/special type
public addFrontMatterByType ( string $type, array $contents )
$type string - special content placed ahead of everything else
$contents array - book contents

addPage() public method

Add a page to the pdf
public addPage ( array $page, array $page_options = [], boolean $display_footer = true, boolean $display_header = true ) : boolean
$page array - the content
$page_options array - numbering reset, style, suppress adding to TOC
$display_footer boolean turn on/off footer display
$display_header boolean turn on/off header display
return boolean

addPartsAndChapters() public method

public addPartsAndChapters ( $contents )

addPreContent() public method

Add all specially handled content.
public addPreContent ( array $contents )
$contents array - the book

addToc() public method

Note, the functionality of the TOC is limited: its behavior varies according mirrored margin settings, and will always generate blank pages after. http://mpdf1.com/forum/discussion/comment/6417#Comment_6417
public addToc ( )

atLeastOneExport() protected method

Does array of chapters have at least one export? Recursive.
protected atLeastOneExport ( array $chapters ) : boolean
$chapters array
return boolean

convert() public method

Book Assembly. Create $this->outputPath
public convert ( ) : boolean
return boolean

fixAnnoyingCharacters() public method

This function prevents mPDF from completely aborting the export routine, or replacing each non-breaking space with a '?' if ignore_invalid_utf8 is true. Important to leave this in.
public fixAnnoyingCharacters ( string $html ) : string
$html string
return string

getBookmarkEntry() public method

Return the PDF bookmark entry for this page should be unique, using static variable for cheap cache
public getBookmarkEntry ( array $page ) : string
$page array
return string

getFilteredContent() public method

Cleans up html
public getFilteredContent ( string $content ) : string
$content string
return string

getFooter() public method

Return formatted footers.
public getFooter ( boolean $display = true, string $content = '' ) : string
$display boolean
$content string The post type being added to the page.
return string

getHeader() public method

Return formatted headers.
public getHeader ( boolean $display = true, string $content = '' ) : string
$display boolean
$content string The post type being added to the page
return string

getOrderedBookContents() public method

Restructures \Pressbooks\Book::getBookContents() into a format more useful for direct iteration, and tracks a nesting level for Bookmark and ToC entries.
public getOrderedBookContents ( ) : array
return array

getThemeCss() public method

Get current child and parent theme css files. Child themes only have one parent theme, and 99% of the time this is 'Luther' or /pressbooks-book/ whose stylesheet is named 'style.css'
public getThemeCss ( object $theme ) : string
$theme object
return string $css

getTocEntry() public method

Return the Table of Contents entry for this page.
public getTocEntry ( string $page ) : string
$page string
return string

hasDependencies() static public method

Dependency check.
static public hasDependencies ( ) : boolean
return boolean

isPdf() protected method

Verify if file has 'application/pdf' mimeType.
protected isPdf ( string $file ) : boolean
$file string
return boolean

setCss() public method

Add all css files
public setCss ( )

validate() public method

Check the sanity of $this->outputPath
public validate ( ) : boolean
return boolean

Property Details

$bookMeta protected property

Book Metadata
protected array $bookMeta
return array

$bookTitle protected property

Holds the title of the book being published
protected string $bookTitle
return string

$exportStylePath protected property

Fullpath to book CSS file.
protected string $exportStylePath
return string

$globalOptions protected property

Global theme options, set by the user
protected array $globalOptions
return array

$memoryNeeded protected property

mPDF uses a lot of memory, this the recommended minimum
See also: http://mpdf1.com/manual/index.php?tid=408
protected int $memoryNeeded
return integer

$mpdf protected property

MPDF Class
protected object $mpdf
return object

$numbered protected property

Number the chapters
protected bool $numbered
return boolean

$options protected property

mPDF theme options, set by the user
protected array $options
return array