/** * Save PHPExcel to file * * @param string $pFilename Name of the file to save as * @throws PHPExcel_Writer_Exception */ public function save($pFilename = null) { $fileHandle = parent::prepareForSave($pFilename); // Default PDF paper size $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) // Check for paper size and page orientation if (is_null($this->getSheetIndex())) { $orientation = $this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P'; $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); } else { $orientation = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P'; $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); } $this->setOrientation($orientation); // Override Page Orientation if (!is_null($this->getOrientation())) { $orientation = $this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT ? PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT : $this->getOrientation(); } $orientation = strtoupper($orientation); // Override Paper Size if (!is_null($this->getPaperSize())) { $printPaperSize = $this->getPaperSize(); } if (isset(self::$paperSizes[$printPaperSize])) { $paperSize = self::$paperSizes[$printPaperSize]; } // Create PDF $pdf = new mpdf(); $ortmp = $orientation; $pdf->_setPageSize(strtoupper($paperSize), $ortmp); $pdf->DefOrientation = $orientation; $pdf->AddPage($orientation); // Document info $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle()); $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator()); $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject()); $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords()); $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator()); $pdf->WriteHTML($this->generateHTMLHeader(false) . $this->generateSheetData() . $this->generateHTMLFooter()); // Write to file fwrite($fileHandle, $pdf->Output('', 'S')); parent::restoreStateAfterSave($fileHandle); }
public function studentPdf(Request $request) { $post = $request->all(); $user = $post['student']; $std = student::where('studentNo', '=', $user)->first(); $charge = charges::where('students_studentNo', '=', $user)->first(); $serial = Serial::where('students_studentNo', '=', $user)->first(); if ($charge->total == 0) { $html = PDF::make($std, $serial); } else { $html = PDF::create($std, $charge, $serial); } $mpdf = new mpdf(); $mpdf->WriteHTML($html); $mpdf->Output(); }
$pdf_message = "Sorry Reservation is Unsuccessful. Thank you for choosing Roomista.com as your booking engine"; } ob_start(); include dirname(__FILE__) . "/res/voucher_template.php"; $content = ob_get_clean(); require_once dirname(__FILE__) . '/../mPDF/mpdf.php'; try { $pdf = new mpdf('', strtoupper('A4'), 0, 'Arial, Helvetica, sans-serif', 20, 15, 20, 5, 0, 0, 'L'); $pdf->AddPage($orientation); // Document info $pdf->SetTitle("Customer Invoice"); $pdf->SetAuthor("roomista.com"); $pdf->SetSubject("Customer Invoice"); $pdf->SetKeywords("Customer Invoice"); $pdf->SetCreator("roomista.com"); $pdf->WriteHTML(utf8_encode($content)); $filename = "Reservation_client_invoice.pdf"; if ($_REQUEST['force'] == 'email') { $content = $pdf->Output('invoive.pdf', 'S'); $content = chunk_split(base64_encode($content)); $mail = new PHPMailer(); $body = "<table width='745' style='font-family: Arial, Helvetica, sans-serif'>\n <tr>\n <td width='745' style='text-align: center; font-size: 20pt;'>Congratulations</td>\n </tr>\n <tr>\n <td height='25' ></td>\n </tr>\n <tr>\n <td width='745' style='text-align: center; font-size: 14pt; '>Your reservation was successfully completed</td>\n </tr>\n <tr>\n <td height='10' ></td>\n </tr>\n <tr>\n <td width='745' style='text-align: left; font: 700 '>We have attached the customer invoice for your reference. Do have a copy of the same when checking in at the hotel.</td>\n </tr>\n <tr>\n <td width='745' style='text-align: left; font: 700 '>Wishing you a pleasant stay.</td>\n </tr>\n <tr>\n <td width='745' style='text-align: left; font: 700 '>\n <p>\n --<br/>\n Kind regards<br>\n System Administrator, <br>\n <strong><a href='roomista.com'>roomista.com</a></strong>\n </p>\n <br/><br/><br/>\n <hr/>\n <span style='color:#CCC; font-size:10px; font-family:Arial, Helvetica, sans-serif;'>This e-mail is confidential. It may also be legally privileged. If you are not the intended recipient or have received it in error, please delete it and all copies from your system and notify the sender immediately by return e-mail. Any unauthorized reading, reproducing, printing or further dissemination of this e-mail or its contents is strictly prohibited and may be unlawful. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions.</span>\n </td>\n </tr>\n </table>"; //Headers of PDF and e-mail $boundary = "XYZ-" . date("dmYis") . "-ZYX"; $header = "--{$boundary}\r\n"; $header .= "Content-Transfer-Encoding: 8bits\r\n"; $header .= "Content-Type: text/html; charset=ISO-8859-1\r\n\r\n"; //plain $header .= "{$body}\r\n"; $header .= "--{$boundary}\r\n"; $header .= "Content-Type: application/pdf; name=\"" . $filename . "\"\r\n";
$pdf = new mpdf('', // mode - default '' strtoupper($paperSize), // format - A4, for example, default '' 0, // font size - default 0 'segoeui', // default font family $printMargins->getLeft()*15, // margin_left $printMargins->getRight()*15, // margin right $printMargins->getTop()*15, // margin top $printMargins->getBottom()*15, // margin bottom 0, // margin header 0, // margin footer $orientation // L - landscape, P - portrait ); $pdf->AddPage($orientation); // Document info $pdf->SetTitle("Customer Invoice"); $pdf->SetAuthor("roomista.com"); $pdf->SetSubject("Customer Invoice"); $pdf->SetKeywords("Customer Invoice"); $pdf->SetCreator("roomista.com"); $pdf->WriteHTML( $this->generateHTMLHeader(FALSE) . $this->generateSheetData() . $this->generateHTMLFooter() ); // Write to file fwrite($fileHandle, $pdf->Output('', 'S'));
public static function report() { $appliedStudents = DB::table('students')->count(); $clearedStudentsFac = DB::table('cleared_by')->where('cleared_by.department_cleared_by', '!=', 'N/A')->count(); $pendingStudentsFac = DB::table('cleared_by')->where('cleared_by.department_cleared_by', '=', 'N/A')->count(); //cafeteria $clearedStudentsCaf = DB::table('cleared_by')->where('cleared_by.cafeteria_cleared_by', '!=', 'N/A')->count(); $pendingStudentsCaf = DB::table('cleared_by')->where('cleared_by.cafeteria_cleared_by', '=', 'N/A')->count(); //library $clearedStudentsLib = DB::table('cleared_by')->where('cleared_by.library_cleared_by', '!=', 'N/A')->count(); $pendingStudentsLib = DB::table('cleared_by')->where('cleared_by.library_cleared_by', '=', 'N/A')->count(); //Ex-Act $clearedStudentsExa = DB::table('cleared_by')->where('cleared_by.extra_curricular_cleared_by', '!=', 'N/A')->count(); $pendingStudentsExa = DB::table('cleared_by')->where('cleared_by.extra_curricular_cleared_by', '=', 'N/A')->count(); //Games $clearedStudentsGam = DB::table('cleared_by')->where('cleared_by.games_cleared_by', '!=', 'N/A')->count(); $pendingStudentsGam = DB::table('cleared_by')->where('cleared_by.games_cleared_by', '=', 'N/A')->count(); //F-Aid $clearedStudentsFna = DB::table('cleared_by')->where('cleared_by.financial_aid_cleared_by', '!=', 'N/A')->count(); $pendingStudentsFna = DB::table('cleared_by')->where('cleared_by.financial_aid_cleared_by', '=', 'N/A')->count(); //Fin $clearedStudentsFin = DB::table('cleared_by')->where('cleared_by.finance_cleared_by', '!=', 'N/A')->count(); $pendingStudentsFin = DB::table('cleared_by')->where('cleared_by.finance_cleared_by', '=', 'N/A')->count(); //total Students $totalStudentsCleared = DB::table('clearstatus')->where('status', '=', 'Cleared')->count(); $totalStudentsPending = DB::table('clearstatus')->where('status', '=', 'Pending')->count(); //faculty //FIT $reqStudentFIT = DB::table('students')->where('faculty', '=', 'FIT')->count(); $clearedStudentsFIT = DB::table('clearstatus')->join('students', 'clearstatus.students_studentNo', '=', 'students.studentNo')->where('clearstatus.status', '=', 'CLeared')->where('students.faculty', '=', 'FIT')->count(); $pendingStudentsFIT = DB::table('clearstatus')->join('students', 'clearstatus.students_studentNo', '=', 'students.studentNo')->where('clearstatus.status', '=', 'Pending')->where('students.faculty', '=', 'FIT')->count(); //SLS $reqStudentSLS = DB::table('students')->where('faculty', '=', 'SLS')->count(); $clearedStudentsSLS = DB::table('clearstatus')->join('students', 'clearstatus.students_studentNo', '=', 'students.studentNo')->where('clearstatus.status', '=', 'CLeared')->where('students.faculty', '=', 'SLS')->count(); $pendingStudentsSLS = DB::table('clearstatus')->join('students', 'clearstatus.students_studentNo', '=', 'students.studentNo')->where('clearstatus.status', '=', 'Pending')->where('students.faculty', '=', 'SLS')->count(); //SOA $reqStudentSOA = DB::table('students')->where('faculty', '=', 'SOA')->count(); $clearedStudentsSOA = DB::table('clearstatus')->join('students', 'clearstatus.students_studentNo', '=', 'students.studentNo')->where('clearstatus.status', '=', 'CLeared')->where('students.faculty', '=', 'SOA')->count(); $pendingStudentsSOA = DB::table('clearstatus')->join('students', 'clearstatus.students_studentNo', '=', 'students.studentNo')->where('clearstatus.status', '=', 'Pending')->where('students.faculty', '=', 'SOA')->count(); //SHSS $reqStudentSHSS = DB::table('students')->where('faculty', '=', 'SHSS')->count(); $clearedStudentsSHSS = DB::table('clearstatus')->join('students', 'clearstatus.students_studentNo', '=', 'students.studentNo')->where('clearstatus.status', '=', 'CLeared')->where('students.faculty', '=', 'SHSS')->count(); $pendingStudentsSHSS = DB::table('clearstatus')->join('students', 'clearstatus.students_studentNo', '=', 'students.studentNo')->where('clearstatus.status', '=', 'Pending')->where('students.faculty', '=', 'SHSS')->count(); //SFAE $reqStudentSFAE = DB::table('students')->where('faculty', '=', 'SFAE')->count(); $clearedStudentsSFAE = DB::table('clearstatus')->join('students', 'clearstatus.students_studentNo', '=', 'students.studentNo')->where('clearstatus.status', '=', 'CLeared')->where('students.faculty', '=', 'SFAE')->count(); $pendingStudentsSFAE = DB::table('clearstatus')->join('students', 'clearstatus.students_studentNo', '=', 'students.studentNo')->where('clearstatus.status', '=', 'Pending')->where('students.faculty', '=', 'SFAE')->count(); //SOA $reqStudentCHT = DB::table('students')->where('faculty', '=', 'CHT')->count(); $clearedStudentsCHT = DB::table('clearstatus')->join('students', 'clearstatus.students_studentNo', '=', 'students.studentNo')->where('clearstatus.status', '=', 'CLeared')->where('students.faculty', '=', 'CHT')->count(); $pendingStudentsCHT = DB::table('clearstatus')->join('students', 'clearstatus.students_studentNo', '=', 'students.studentNo')->where('clearstatus.status', '=', 'Pending')->where('students.faculty', '=', 'CHT')->count(); //SOA $reqStudentSBS = DB::table('students')->where('faculty', '=', 'SBS')->count(); $clearedStudentsSBS = DB::table('clearstatus')->join('students', 'clearstatus.students_studentNo', '=', 'students.studentNo')->where('clearstatus.status', '=', 'CLeared')->where('students.faculty', '=', 'SBS')->count(); $pendingStudentsSBS = DB::table('clearstatus')->join('students', 'clearstatus.students_studentNo', '=', 'students.studentNo')->where('clearstatus.status', '=', 'Pending')->where('students.faculty', '=', 'SBS')->count(); //financial report //facuty $totalDep = DB::table('charge')->sum('department_value'); //cafeteria $totalCaf = DB::table('charge')->sum('cafeteria_value'); // library $totalLib = DB::table('charge')->sum('library_value'); //Extra Cal $totalExc = DB::table('charge')->sum('extra_curricular_value'); //games $totalGam = DB::table('charge')->sum('games_value'); //financial aid $totalFna = DB::table('charge')->sum('financial_aid_value'); //finance $totalFin = DB::table('charge')->sum('finance_value'); $html = PDF::report($appliedStudents, $clearedStudentsFac, $pendingStudentsFac, $clearedStudentsCaf, $pendingStudentsCaf, $clearedStudentsGam, $pendingStudentsGam, $clearedStudentsExa, $pendingStudentsExa, $clearedStudentsFna, $pendingStudentsFna, $clearedStudentsFin, $pendingStudentsFin, $clearedStudentsLib, $pendingStudentsLib, $totalStudentsCleared, $totalStudentsPending, $reqStudentFIT, $clearedStudentsFIT, $pendingStudentsFIT, $reqStudentSOA, $clearedStudentsSOA, $pendingStudentsSOA, $reqStudentSLS, $clearedStudentsSLS, $pendingStudentsSLS, $reqStudentSFAE, $clearedStudentsSFAE, $pendingStudentsSFAE, $reqStudentCHT, $clearedStudentsCHT, $pendingStudentsCHT, $reqStudentSHSS, $clearedStudentsSHSS, $pendingStudentsSHSS, $reqStudentSBS, $clearedStudentsSBS, $pendingStudentsSBS, $totalDep, $totalCaf, $totalLib, $totalExc, $totalGam, $totalFna, $totalFin); $mpdf = new mpdf(); $mpdf->WriteHTML($html); $mpdf->Output(); }
/** * Save PHPExcel to file * * @param string $pFileName * @throws Exception */ public function save($pFilename = null) { // garbage collect $this->_phpExcel->garbageCollect(); $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); // Open file $fileHandle = fopen($pFilename, 'w'); if ($fileHandle === false) { throw new Exception("Could not open file {$pFilename} for writing."); } // Set PDF $this->_isPdf = true; // Build CSS $this->buildCSS(true); // Default PDF paper size $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) // Check for paper size and page orientation if (is_null($this->getSheetIndex())) { $orientation = $this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P'; $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); } else { $orientation = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P'; $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); } $this->setOrientation($orientation); // Override Page Orientation if (!is_null($this->getOrientation())) { $orientation = $this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT ? PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT : $this->getOrientation(); } $orientation = strtoupper($orientation); // Override Paper Size if (!is_null($this->getPaperSize())) { $printPaperSize = $this->getPaperSize(); } if (isset(self::$_paperSizes[$printPaperSize])) { $paperSize = self::$_paperSizes[$printPaperSize]; } // Create PDF $pdf = new mpdf(); $pdf->_setPageSize(strtoupper($paperSize), $orientation); $pdf->DefOrientation = $orientation; // Document info $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle()); $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator()); $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject()); $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords()); $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator()); $pdf->WriteHTML($this->generateHTMLHeader(false) . $this->generateSheetData() . $this->generateHTMLFooter()); // Write to file fwrite($fileHandle, $pdf->Output('', 'S')); // Close file fclose($fileHandle); PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show() { $user = Auth::user()->regNo; $std = student::where('studentNo', '=', $user)->first(); $charge = charges::where('students_studentNo', '=', $user)->first(); if ($charge->total == 0) { $html = PDF::make($std); } else { $html = PDF::create($std, $charge); } $mpdf = new mpdf(); $mpdf->WriteHTML($html); $mpdf->Output(); }
function front_id($results) { $params = array('mode' => '', 'format' => 'Legal', 'default_font_size' => 0, 'default_font' => '', 'mgl' => '0', 'mgr' => '0', 'mgt' => '0', 'mgb' => '0', 'mgh' => '0', 'mgf' => '0', 'orientation' => 'P'); $this->load->library('mpdf', $params); $mpdf = new mpdf($params); // LOAD a stylesheet //$this->mpdf->SetHTMLHeader('<div align="center" style="font-size:15">LAGUNA UNIVERSITY PROPERTY INVENTORY SYSTEM<div>'); $stylesheet = file_get_contents(base_url() . 'css/mpdf/mpdfstyletables.css'); $mpdf->WriteHTML($stylesheet, 1); // The parameter 1 tells that this is css/style only and no body/html/text //$today = date("F, l, d, Y - H:i:s a"); //$this->mpdf->SetFooter($today.'||{PAGENO} of {nbpg}'); $tbl_start_f = '<table border="0"><tr>'; $mpdf->WriteHTML($tbl_start_f); $x = '4'; //4 start counting $y = '0'; foreach ($results as $result) { $e = new Employee_m(); $row = $e->get_by_id($result->employee_id); $y++; $pics = "pics/" . $row->pics; if (strlen($row->pics) <= '4' || !file_exists($pics)) { $pics = 'pics/not_available.jpg'; } //set font size if textover flow at employee name $s_name = 'height="21" style="font-weight: bold; font-size:15px;"'; if (strlen($row->fname . " " . $row->mname . " " . $row->lname) >= '20') { $s_name = 'height="21" style="font-weight: bold; font-size:10px;"'; } //set font size if textover flow at office code $s_office = 'style="font-weight: bold; font-size:15px; color: #FFF;"'; if (strlen($row->office_code) >= '21') { $s_office = 'style="font-weight: bold; font-size:10px; color: #FFF;"'; } //set font size if textover flow at position $valign_pos = 'valign="middle"'; if (strlen($row->position) >= '45') { $valign_pos = 'valign="bottom"'; } //set font size if textover flow at position $s_position = 'style="font-weight: bold; font-size:15px; color:#FF0;"'; if (strlen($row->position) >= '21') { $s_position = 'style="font-weight: bold; font-size:8px; color:#FF0;"'; } $html_f = '<td align="center"> <table border="0" width="205" height="320" style="background-image: url(images/id/id-front.png);"> <tr> <td align="center" height="63"> </td> </tr> <tr> <td align="center" style="font-weight: bold; font-size:12px;">EMP No:' . strtoupper($row->employee_id) . '</td> </tr> <tr> <td align="center"><img src="' . $pics . '" width="120" height="140"/></td> </tr> <tr> <td align="center" valign="middle" ' . $s_name . '>' . strtoupper($row->fname . " " . $row->mname . " " . $row->lname) . '</td> </tr> <tr> <td align="center" height="34"> </td> </tr> <tr> <td align="center" valign="bottom" height="27" ' . $s_office . '>' . strtoupper($row->office_code) . '</td> </tr> <tr> <td align="center" ' . $valign_pos . ' height="22" ' . $s_position . '>' . strtoupper($row->position) . '</td> </tr> </table></td>'; if ($y == $x) { $html_f = ' <tr><td align="center"> <table border="0" width="205" height="320" style="background-image: url(images/id/id-front.png);"> <tr> <td align="center" height="63"> </td> </tr> <tr> <td align="center" style="font-weight: bold; font-size:12px;">EMP No:' . strtoupper($row->employee_id) . '</td> </tr> <tr> <td align="center"><img src="' . $pics . '" width="120" height="140"/></td> </tr> <tr> <td align="center" valign="middle" ' . $s_name . '>' . strtoupper($row->fname . " " . $row->mname . " " . $row->lname) . '</td> </tr> <tr> <td align="center" height="34"> </td> </tr> <tr> <td align="center" valign="bottom" height="27" ' . $s_office . '>' . strtoupper($row->office_code) . '</td> </tr> <tr> <td align="center" ' . $valign_pos . ' height="22" ' . $s_position . '>' . strtoupper($row->position) . '</td> </tr> </table></td></tr>'; $x = $x + 3; //3 count of generated id per column } $mpdf->WriteHTML($html_f); } $tbl_end_f = '</tr></table>'; $mpdf->WriteHTML($tbl_end_f); header('Cache-Control: maxage=3600'); //Adjust maxage appropriately header('Pragma: public'); $mpdf->Output('dtr/template/id_generated/front_id.pdf', 'F'); //return 'dtr/template/id_generated/front_id_'.date('Y_m_d').'.pdf'; }
/** * Save PHPExcel to file * * @param string $pFileName * @throws Exception */ public function save($pFilename = null) { // garbage collect $this->_phpExcel->garbageCollect(); $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); // Open file $fileHandle = fopen($pFilename, 'w'); if ($fileHandle === false) { throw new Exception("Could not open file $pFilename for writing."); } // Set PDF $this->_isPdf = true; // Build CSS $this->buildCSS(true); if(!$this->_printParamsSetted) { // Default PDF paper size $paperSize = 'A4'; // Check for paper size and page orientation if (is_null($this->getSheetIndex())) { $orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); } else { $orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); } $this->setOrientation($orientation); // Override Page Orientation if (!is_null($this->getOrientation())) { $orientation = ($this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT) ? PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT : $this->getOrientation(); } $orientation = strtoupper($orientation); // Override Paper Size if (!is_null($this->getPaperSize())) { $printPaperSize = $this->getPaperSize(); } if (isset(self::$_paperSizes[$printPaperSize])) { $paperSize = self::$_paperSizes[$printPaperSize]; } if(is_string($paperSize)){ $paperSize = strtoupper($paperSize.(substr($orientation,0,1) == 'L' ? '-L' : '')); } if($printMargins) { //$printMargins是英寸制,要转换成毫米 $tmargin = 25.4 * $printMargins->getTop(); $bmargin = 25.4 * $printMargins->getBottom(); $lmargin = 25.4 * $printMargins->getLeft(); $rmargin = 25.4 * $printMargins->getRight(); $hmargin = 25.4 * $printMargins->getHeader(); $fmargin = 25.4 * $printMargins->getFooter(); } } else { $paperSize = $this->_printPaperSize; $orientation = $this->_printOrientation; $tmargin = $this->_printTmargin; $bmargin = $this->_printBmargin; $lmargin = $this->_printLmargin; $rmargin = $this->_printRmargin; $hmargin = $this->_printHmargin; $fmargin = $this->_printFmargin; } error_reporting(E_ALL ^ E_NOTICE); //当前的版本很多notice警告,屏蔽掉 // Create PDF $pdf = new mpdf(); $pdf->useAdobeCJK = true; // Default setting in config.php $pdf->SetAutoFont(AUTOFONT_ALL); // AUTOFONT_CJK | AUTOFONT_THAIVIET | AUTOFONT_RTL | AUTOFONT_INDIC // AUTOFONT_ALL // Log::write("\ndefault pdf:\nT:".$pdf->tMargin."\nB:".$pdf->bMargin."\nL:".$pdf->DeflMargin."\nR:".$pdf->DefrMargin."\nH:".$pdf->margin_header."\nF:".$pdf->margin_footer."\n\n"); $pdf->_setPageSize($paperSize, $orientation); $pdf->DefOrientation = $orientation; if(!empty($this->_printFooterO)) { $pdf->SetHTMLFooter($this->_printFooterO); } if(!empty($this->_printHeaderO)) { $pdf->SetHTMLHeader($this->_printHeaderO, 'O'); } if(!empty($this->_printFooterE)) { $pdf->SetHTMLFooter($this->_printFooterE, 'E'); } if(!empty($this->_printHeaderE)) { $pdf->SetHTMLHeader($this->_printHeaderE, 'E'); } if(!empty($tmargin)) { $pdf->tMargin = $tmargin; } if(!empty($bmargin)) { $pdf->bMargin = $bmargin; } if(!empty($lmargin)) { $pdf->DeflMargin = $lmargin; } if(!empty($rmargin)) { $pdf->DefrMargin = $rmargin; } if(!empty($hmargin)) { $pdf->margin_header = $hmargin; } if(!empty($fmargin)) { $pdf->margin_footer = $fmargin; } $pdf->mirrorMargins = $this->_mirrorMargins; if(!empty($this->_script)) { $pdf->SetJS($this->_script); } // Document info $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle()); $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator()); $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject()); $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords()); $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator()); $pdf->WriteHTML( $this->generateHTMLHeader(false) . $this->generateSheetData() . $this->generateHTMLFooter() ); // Write to file fwrite($fileHandle, $pdf->Output('','S')); // Close file fclose($fileHandle); PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType); }