将tcpdf与bengali语言一起使用(所有其他语言都很好)时,我遇到了一些问题。我发现孟加拉语字体Nikosh.ttf(试过另一个,但只有Bengal问题相同)新行上的每个符号,但在文本中它在一行。如何解决这个问题?需要在写入时显示文本。
$pdf = new tFPDF();
$pdf->AddPage();
$pdf->AddFont('Nikosh','','Nikosh.ttf',true);
$pdf->SetFont('Nikosh','',14);
$txt = file_get_contents('HelloWorld.txt');
$pdf->Write(8,$txt);
$pdf->Output();
HelloWorld.txt包含
English: Hello World
Bengali: দৃষ্টিতে স্বল্পসংখ্যক ছিলেন
我得到了什么 https://drive.google.com/file/d/0ByCB3iOJZXTLQ1lubG16dlpaREU/view?usp=sharing 谢谢你的帮助
答案 0 :(得分:0)
试试这个:
<?php
require_once('tcpdf_include.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, 15, PDF_MARGIN_RIGHT);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, 15);
// set image scale factor
//$pdf->setImageScale(1);
// add a page
$pdf->AddPage();
$strBNFont = TCPDF_FONTS::addTTFfont('Nikosh.ttf', 'TrueTypeUnicode', '', 32);
$pdf->SetFont($strBNFont, '', 14, '', 'true');
//$pdf->SetFont('times', '', 8);
$txt = "English: Hello World
Bengali: দৃষ্টিতে স্বল্পসংখ্যক ছিলেন ";
$pdf->Write(0, $txt, '', 0, 'C', true, 0, false, false, 0);
//Close and output PDF document
//$pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/' . time() . '.pdf', 'F');
$pdf->Output();
//echo 'done';