/**
  * Creates the PDF and does a specific output (see PDF_Generator function above for $output variable types)
  */
 public function PDF_processing($html, $filename, $id, $output = 'view', $arguments)
 {
     /* 
      * DOMPDF replaced with mPDF in v3.0.0 
      * Check which version of mpdf we are calling
      * Full, Lite or Tiny
      */
     if (!class_exists('mPDF')) {
         if (FP_PDF_ENABLE_MPDF_TINY === true) {
             include FP_PDF_PLUGIN_DIR . '/mPDF/mpdf-extra-lite.php';
         } elseif (FP_PDF_ENABLE_MPDF_LITE === true) {
             include FP_PDF_PLUGIN_DIR . '/mPDF/mpdf-lite.php';
         } else {
             include FP_PDF_PLUGIN_DIR . '/mPDF/mpdf.php';
         }
     }
     /* 
      * Initialise class and set the paper size and orientation
      */
     $paper_size = $arguments['pdf_size'];
     if (!is_array($paper_size)) {
         $orientation = $arguments['orientation'] == 'landscape' ? '-L' : '';
         $paper_size = $paper_size . $orientation;
     } else {
         $orientation = $arguments['orientation'] == 'landscape' ? 'L' : 'P';
     }
     $mpdf = new mPDF('', $paper_size, 0, '', 15, 15, 16, 16, 9, 9, $orientation);
     /*
      * Display PDF is full-page mode which allows the entire PDF page to be viewed
      * Normally PDF is zoomed right in.
      */
     $mpdf->SetDisplayMode('fullpage');
     if (FP_PDF_ENABLE_SIMPLE_TABLES === true) {
         $mpdf->simpleTables = true;
     }
     /*
      * Automatically detect fonts and substitue as needed
      */
     if (FP_PDF_DISABLE_FONT_SUBSTITUTION === true) {
         $mpdf->useSubstitutions = false;
     } else {
         $mpdf->SetAutoFont(AUTOFONT_ALL);
         $mpdf->useSubstitutions = true;
     }
     /*
      * Set Creator Meta Data
      */
     $mpdf->SetCreator('Formidable Pro PDF Extended v' . FP_PDF_EXTENDED_VERSION . '. http://formidablepropdfextended.com');
     /*
      * Set RTL languages at user request
      */
     if ($arguments['rtl'] === true) {
         $mpdf->SetDirectionality('rtl');
     }
     /*
      * Set up security if user requested
      */
     if ($arguments['security'] === true && $arguments['pdfa1b'] !== true && $arguments['pdfx1a'] !== true) {
         $password = strlen($arguments['pdf_password']) > 0 ? $arguments['pdf_password'] : '';
         $master_password = strlen($arguments['pdf_master_password']) > 0 ? $arguments['pdf_master_password'] : null;
         $pdf_privileges = is_array($arguments['pdf_privileges']) ? $arguments['pdf_privileges'] : array();
         $mpdf->SetProtection($pdf_privileges, $password, $master_password, 128);
     }
     /* PDF/A1-b support added in v3.4.0 */
     if ($arguments['pdfa1b'] === true) {
         $mpdf->PDFA = true;
         $mpdf->PDFAauto = true;
     } else {
         if ($arguments['pdfx1a'] === true) {
             $mpdf->PDFX = true;
             $mpdf->PDFXauto = true;
         }
     }
     /*
      * Check if we should auto prompt to print the document on open
      */
     if (isset($_GET['print'])) {
         $mpdf->SetJS('this.print();');
     }
     /* load HTML block */
     $mpdf->WriteHTML($html);
     switch ($output) {
         case 'download':
             $mpdf->Output($filename, 'D');
             exit;
             break;
         case 'view':
             $mpdf->Output(time(), 'I');
             exit;
             break;
         case 'save':
             /*
              * PDF wasn't writing to file with the F method - http://mpdf1.com/manual/index.php?tid=125
              * Return as a string and write to file manually
              */
             $pdf = $mpdf->Output('', 'S');
             return $this->savePDF($pdf, $filename, $id);
             break;
     }
 }
            // If it is just a word use it as an index entry
            if (preg_match("/^(&#x[0]{0,1}6[0-9a-f][0-9a-f];){4,30}\$/i", $w) && $y > 8) {
                $content = trim($w);
                $html .= '<indexentry content="' . $content . '" />';
            }
            $html .= $w;
        }
    } else {
        $html .= '<' . $e . '>';
    }
}
//==============================================================
//==============================================================
require_once __DIR__ . '/../vendor/autoload.php';
$mpdf = new mPDF('', 'A4', '', '', 32, 25, 27, 25, 16, 13);
$mpdf->SetDirectionality('rtl');
$mpdf->mirrorMargins = true;
$mpdf->SetDisplayMode('fullpage', 'two');
$mpdf->autoLangToFont = true;
$mpdf->defaultPageNumStyle = 'arabic-indic';
$mpdf->setHeader($h);
$mpdf->setFooter($f);
$mpdf->debug = true;
$stylesheet = file_get_contents('mpdfstyletables.css');
$mpdf->WriteHTML($stylesheet, 1);
// The parameter 1 tells that this is css/style only and no body/html/text
$mpdf->WriteHTML($html);
$mpdf->AddPage();
$mpdf->SetColumns(2, 'J');
$mpdf->WriteHTML($html);
$mpdf->SetColumns(0);
Example #3
0
<?php

include "../mpdf-6.1.2/mpdf.php";
$html_data = file_get_contents("body-cn.html");
$style_data = file_get_contents("style-cn.css");
// Create new PDF with font subsetting, 210mm wide, 297mm high
$mpdf = new mPDF('s', array(210, 297));
// Make it a double sided document with 4mm bleed
$mpdf->mirrorMargins = 1;
$mpdf->bleedMargin = 4;
// Set left to right text
$mpdf->SetDirectionality('ltr');
// Generate the table of contents from H3 elements
$mpdf->h2toc = array('H3' => 0);
// Write the stylesheet
$mpdf->WriteHTML($style_data, 1);
// The parameter 1 tells mPDF that this is CSS and not HTML
// Write the main text
$mpdf->WriteHTML($html_data, 2);
// Set the metadata
$mpdf->SetTitle("An Example Title");
$mpdf->SetAuthor("Cicero");
$mpdf->SetCreator("mPDF 6.1.2");
$mpdf->SetSubject("Lorem Ipsum");
$mpdf->SetKeywords("Lorem, Ipsum");
// Generate the PDF file
$mpdf->Output('chinese.pdf', 'F');
// Stop mPDF
exit;
?>