Last active
August 17, 2017 18:58
-
-
Save Dinamiko/24855672b1d63f3a6604a9cc7805f2f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// creating and setting the pdf | |
$mpdf = new mPDF('utf-8', $format, $dkpdf_font_size, $dkpdf_font_family, | |
$dkpdf_margin_left, $dkpdf_margin_right, $dkpdf_margin_top, $dkpdf_margin_bottom, $dkpdf_margin_header | |
); | |
// write cover | |
$dkpdf_show_cover = get_option( 'dkpdfg_show_cover', 'on' ); | |
if( $dkpdf_show_cover == 'on' ) { | |
$pdf_cover = dkpdfg_get_template( 'dkpdfg-cover' ); | |
$mpdf->WriteHTML( $pdf_cover ); | |
} | |
// write TOC | |
$dkpdf_show_toc = get_option( 'dkpdfg_show_toc', 'on' ); | |
if( $dkpdf_show_toc == 'on' ) { | |
$toc_title = get_option( 'dkpdfg_toc_title', 'Table of contents' ); | |
$mpdf->WriteHTML('<tocpagebreak toc-preHTML="<h2>'. $toc_title .'</h2>" paging="on" links="on" resetpagenum="1" toc-odd-footer-value="-1" toc-odd-header-value="-1" />'); | |
$mpdf->h2toc = array( 'H1'=>0 ); | |
$mpdf->h2bookmarks = array( 'H1'=>0 ); | |
} | |
// header | |
$pdf_header_html = dkpdf_get_template( 'dkpdf-header' ); | |
$mpdf->SetHTMLHeader( $pdf_header_html, 'O', TRUE ); | |
// footer | |
$pdf_footer_html = dkpdf_get_template( 'dkpdf-footer' ); | |
$mpdf->SetHTMLFooter( $pdf_footer_html ); | |
// write content | |
$mpdf->WriteHTML( dkpdfg_get_template( 'dkpdfg-index' ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment