Php 使用TCPDF将空间写入PDF文件

Php 使用TCPDF将空间写入PDF文件,php,pdf,whitespace,tcpdf,Php,Pdf,Whitespace,Tcpdf,我有一个简单的脚本,它将一些文本写入php库TCPDF的PDF文件中。 以下是脚本: // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Label C

我有一个简单的脚本,它将一些文本写入php库TCPDF的PDF文件中。 以下是脚本:

// create new PDF document 
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Label Creator');
$pdf->SetTitle('labels');
$pdf->SetSubject('Labels di prova');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUE,0);

//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings
$pdf->setLanguageArray($l);

// set font
$pdf->SetFont('times', '', 15);
//left margin
$pdf->SetMargins(18,15,18,FALSE);
// add a page
$pdf->AddPage();
$label="Hello world, i'm michele";

$pdf->Cell(0, 0 , $label, 0, 1, 'C', 0, '', 0,FALSE,'T','M');

//Close and output PDF document
$pdf->Output('../../labels.pdf', 'F');
echo 'Labels generate!';
问题是脚本可以工作,但在文件中我将看到没有空格的文本!这样地: 你好,我是米切尔
有人有解决办法吗

选项1:如果要使用单元格

原型是:

//Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=0, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M')
要处理间距,请使用以下命令:

您可以尝试以下方法:

边框处于打开状态,以便您可以查看单元格是否足够大。希望这能奏效。 (对于指示,以下内容:FALSE、'T'、'M'已经是默认值)

选项2:也可以使用Write()

$pdf->AddPage();
//设置一些要打印的文本

$label=我认为问题在于“times”字体。我对那种字体也有同样的问题。您可以尝试tcpdf字体目录中的一些其他字体。

我已经解决了,问题是浏览器的PDF插件可视化工具存在错误

对不起,但是$label=“你好,世界,我是米歇尔”$pdf->Cell(0,0,$label,1,1,'C',0',3;不写空格…我已解决,问题是浏览器的pdf插件可视化工具存在错误!!我已解决,问题是浏览器的pdf插件可视化工具存在错误!!
$pdf->Cell(0, 0, 'TEST CELL STRETCH: spacing', 1, 1, 'C', 0, '', 3);
$pdf->Cell(0, 0, 'TEST CELL STRETCH: force spacing', 1, 1, 'C', 0, '', 4);
$label="Hello world, i'm michele";
$pdf->Cell(0, 0 , $label, 1, 1, 'C', 0, '', 3;
$pdf->AddPage();

// set some text to print
$label = <<<EOD
About Michele.

Michele is awesome.
EOD;

// print a block of text using Write()
$pdf->Write($h=0, $label, $link='', $fill=0, $align='C', $ln=true, $stretch=0, $firstline=false, $firstblock=false, $maxh=0);