Phpexcel Export PDF file garbled, how to solve

Source: Internet
Author: User
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!
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.