Pressbooks\Modules\Export\Mpdf\Pdf::addPage PHP Method

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
    function addPage($page, $page_options = array(), $display_footer = true, $display_header = true)
    {
        // defaults
        $defaults = array('suppress' => 'off', 'resetpagenum' => 0, 'pagenumstyle' => 1, 'margin-right' => $this->options['mpdf_right_margin'], 'margin-left' => $this->options['mpdf_left_margin'], 'sheet-size' => $this->options['mpdf_page_size']);
        $options = \wp_parse_args($page_options, $defaults);
        $class = $this->numbered ? '<div class="' . $page['post_type'] . '">' : '<div class="' . $page['post_type'] . ' numberless">';
        $toc_entry = 'chapter' == $page['post_type'] && true === $this->numbered ? $page['chapter_num'] . ' ' . $page['post_title'] : $page['post_title'];
        if (!empty($page['post_content']) || 'part' == $page['post_type']) {
            $this->mpdf->SetFooter($this->getFooter($display_footer, $this->bookTitle . '| | {PAGENO}'));
            $this->mpdf->SetHeader($this->getHeader($display_header, ''));
            $this->mpdf->AddPageByArray($options);
            if (empty($page['mpdf_omit_toc'])) {
                $this->mpdf->TOC_Entry($this->getTocEntry($toc_entry), $page['mpdf_level']);
                $this->mpdf->Bookmark($this->getBookmarkEntry($page), $page['mpdf_level']);
            }
            if ('chapter' == $page['post_type']) {
                $title = '<h3 class="chapter-number">' . $page['chapter_num'] . '</h3><h2 class="entry-title">' . $page['post_title'] . '</h2>';
            } else {
                $title = '<h2 class="entry-title">' . $page['post_title'] . '</h2>';
            }
            $content = $class . $title . $this->getFilteredContent($page['post_content']) . '</div>' . apply_filters('pb_append_chapter_content', '', $page['ID']);
            // TODO Make this hookable.
            $this->mpdf->WriteHTML($content);
            return true;
        }
        return false;
    }