tfpdf php孟加拉语和新行
我有一个小问题,当使用tcpdf与孟加拉语(所有其他语言工作良好)。我发现孟加拉语字体Nikosh.ttf(尝试了另一种字体,但只有孟加拉语版本是相同的)每一个符号都在新的一行,但在文本中它在一行。如何解决这个问题?需要在写入时显示文本。tfpdf php孟加拉语和新行,php,pdf,Php,Pdf,我有一个小问题,当使用tcpdf与孟加拉语(所有其他语言工作良好)。我发现孟加拉语字体Nikosh.ttf(尝试了另一种字体,但只有孟加拉语版本是相同的)每一个符号都在新的一行,但在文本中它在一行。如何解决这个问题?需要在写入时显示文本。 $pdf = new tFPDF(); $pdf->AddPage(); $pdf->AddFont('Nikosh','','Nikosh.ttf',true); $pdf->SetFont('Nikosh','',14); $txt
$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: দৃষ্টিতে স্বল্পসংখ্যক ছিলেন
我得到了什么
感谢您的帮助试试这个:
<?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';
在写入文件之前尝试剥离新行字符。删除所有\n\r\s,但仍在新行$txt=preg\u replace('/[\n\r\s]/','',file\u get\u contents('HelloWorld.txt');是的,我知道tcpdf,但它比TFPDFan大得多,慢得多,而且tcpdf也不能像需要的那样写得很好