Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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="&lt;h2&gt;'. $toc_title .'&lt;/h2&gt;" 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
You can’t perform that action at this time.