используя PHP > 7 и MySQL
'char_set' => utf8mb4
'dbcollat' => utf8mb4_unicode_ci
Я создал PDF из html, эхо HTML-текста, все смайлы отображаются хорошо. но если он создает PDF-файл, он не конвертируется.
Пожалуйста, помогите решить эту проблему.
пример: «Один \ ud83d\ude02"
спасибо
Вот дополнительное объяснение, чтобы упростить мой вопрос.
Код: Выделить всё
$fileName = $source_path.'example.pdf';
//using php codeignitor 3.1.2
$htmlContent = $this->load->view('view/view_pdf', $data, TRUE);
$htmlContent = [b] Start Time:[/b]
Код: Выделить всё
public function createPDF($fileName, $htmlContent) {
/*
http://www.tcpdf.org
// File name : tcpdf.php
// Version : 6.2.13
// Begin : 2002-08-03
// Last Update : 2015-06-18
*/
ob_start();
// Include the main TCPDF library (search for installation path).
$this->load->library(array('Tcpdf'));
// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
//$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, false, 'ISO-8859-1', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('auth');
$pdf->SetTitle('Event ');
$pdf->SetSubject('Event ');
$pdf->SetKeywords('Event ');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, 10, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(10);
$pdf->SetFooterMargin(30);
// set auto page breaks
//$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->SetAutoPageBreak(TRUE, 30);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
$pdf->SetFont('dejavusans', '', 10);
//$pdf->SetFont('halvatica', '', 10); // this is also trying but fail
// add a page
$pdf->AddPage();
//$htmlContent = utf8_encode($htmlContent);// this is also trying but fail
// output the HTML content
$pdf->writeHTML($htmlContent, true, false, true, false, '');
// reset pointer to the last pagend output PDF document
$pdf->lastPage();
ob_end_clean();
//Close and output PDF document
$pdf->Output($fileName, 'F');
}
Подробнее здесь: https://stackoverflow.com/questions/589 ... -using-php