useAdobeCJK = true; $mpdf->autoScriptToLang = true; if (IP_DEBUG) { // Enable image error logging $mpdf->showImageErrors = true; } // Include zugferd if enabled if ($zugferd_invoice) { $CI->load->helper('zugferd'); $mpdf->PDFA = true; $mpdf->PDFAauto = true; $mpdf->SetAdditionalXmpRdf(zugferd_rdf()); $mpdf->SetAssociatedFiles($associated_files); } // Set a password if set for the voucher if (!empty($password)) { $mpdf->SetProtection(array('copy', 'print'), $password, $password); } // Check if the archive folder is available if (!(is_dir('./uploads/archive/') || is_link('./uploads/archive/'))) { mkdir('./uploads/archive/', '0777'); } // Set the footer if voucher is invoice and if set in settings if (!empty($CI->mdl_settings->settings['pdf_invoice_footer'])) { $mpdf->setAutoBottomMargin = 'stretch'; $mpdf->SetHTMLFooter(''); } $mpdf->WriteHTML($html); if ($isInvoice) { foreach (glob(UPLOADS_FOLDER . 'archive/*' . $filename . '.pdf') as $file) { array_push($invoice_array, $file); } if (!empty($invoice_array) && !is_null($is_guest)) { rsort($invoice_array); if ($stream) { return $mpdf->Output($filename . '.pdf', 'I'); } else { return $invoice_array[0]; } } $archived_file = UPLOADS_FOLDER . 'archive/' . date('Y-m-d') . '_' . $filename . '.pdf'; $mpdf->Output($archived_file, 'F'); if ($stream) { return $mpdf->Output($filename . '.pdf', 'I'); } else { return $archived_file; } } // If $stream is true (default) the PDF will be displayed directly in the browser // otherwise will be returned as a download if ($stream) { return $mpdf->Output($filename . '.pdf', 'I'); } else { $mpdf->Output(UPLOADS_FOLDER . 'temp/' . $filename . '.pdf', 'F'); // Housekeeping // Delete any files in temp/ directory that are >1 hrs old $interval = 3600; if ($handle = @opendir(preg_replace('/\/$/', '', './uploads/temp/'))) { while (false !== ($file = readdir($handle))) { if (($file != '..') && ($file != '.') && !is_dir($file) && ((filemtime('./uploads/temp/' . $file) + $interval) < time()) && (substr($file, 0, 1) !== '.') && ($file != 'remove.txt')) { // mPDF 5.7.3 unlink(UPLOADS_FOLDER . 'temp/' . $file); } } closedir($handle); } return UPLOADS_FOLDER . 'temp/' . $filename . '.pdf'; } }