Phpexcel Exporting PDF files garbled
The code procedure is to read the template file Template.xls. Write the corresponding content and export the PDF file. The Template.xls file contains tables and Japanese. Personally think that there is no font for the reason, but how to correspond to the King Prawn told!!!
Require_once ' excel/phpexcel.php ';
$objPHPExcel = Phpexcel_iofactory::load ("Template.xls");
$objPHPExcel->setactivesheetindex (0);
$objWorksheet = $objPHPExcel->getactivesheet ();
Write content
$objWorksheet->getcell ("C1")->setvalue ("test");
Fake film
$objDrawing = new phpexcel_worksheet_drawing ();
$objDrawing->setname (' Stamp ');
$objDrawing->setdescription ("AAAA");
$objDrawing->setpath ("images/p1.jpg");
$objDrawing->setcoordinates (' M1 ');
$objDrawing->setoffsetx (25);
$objDrawing->setrotation (36);
$objDrawing->setheight (73);
$objDrawing->getshadow ()->setvisible (true);
$objDrawing->getshadow ()->setdirection (45);
$objDrawing->setworksheet ($objWorksheet);
$objWorksheet->settitle (' simple ');
Ob_end_clean ();
Header (' content-type:application/pdf ');
Header (' content-disposition:attachment;filename= ' detail.pdf "');
Header (' cache-control:max-age=0 ');
$objWriter = Phpexcel_iofactory::createwriter ($objPHPExcel, ' PDF ');
$objWriter->save (' php://output ');
Exit
------to solve the idea----------------------
Do you make sure that the content text is UTF-8 encoded? If it is not necessary to use Iconv conversion code.
------to solve the idea----------------------
Phpexcel generates a PDF with a major flaw: if you have a picture in Excel, the resulting PDF will not be retained, so you can use this to generate PDF files is not the best solution!