我创建了下面的代码,用于在tcpdf中使用arial unicode字体显示hindi文本
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set some language-dependent strings
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
$pdf->addTTFfont('fonts/ARIALUNI.TTF', 'TrueTypeUnicode', '', 32);
$pdf->SetFont('arialuni', '', 10,'false');
$txt = 'hindi text with arial unicode ???????';
$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0);
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_038.pdf', 'I');
Run Code Online (Sandbox Code Playgroud)
但它没有正确显示
但在PHP中它显示正确的文本.
请告诉我是否有任何错误.
我收到这样的错误
致命错误:在第 15 行 /Applications/XAMPP/xamppfiles/htdocs/colorlib-search-23/test.php 中找不到类“TableRows”
这是我的代码:
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM users");
$stmt->execute();
// set the resulting array to associative
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
echo $v;
}
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
Run Code Online (Sandbox Code Playgroud)
检查了数据库表的名称和所有复制粘贴的其他代码,但仍然不起作用
$servername = "localhost";
$username = "root";
$password = "";
$dbname = …Run Code Online (Sandbox Code Playgroud)