我刚开始使用FPDF,但是我的文档中存在一个行换行不起作用的问题。
Ln()函数将使我返回到当前所在行的开头。这只是一个烦人,因为我通过传递给它一个设置值来分隔行来克服了它。
我的主要问题是,使用MultiCell()时,当涉及\ n时,它仅到达同一行的开头,并将所有文本堆积在一起。
码:
<?php
require_once('fpdf/fpdf.php');
$lineBreak=0.21;
$pdf = new FPDF('P','in',array(4,6));
$pdf->AddPage();
$pdf->SetMargins(0.2,0.2,0.2);
$pdf->SetFont('Times','BU',12);
$pdf->SetXY(0.2,0.3);
$pdf->Cell(0,0,'Part Number:',0,2,'L',false);
$pdf->SetFont('Times','B',12);
$pdf->SetXY(0.2,0.3);
$pdf->Cell(0,0,'Item 1',0,1,'R',false);
$pdf->Ln($lineBreak);
$pdf->SetFont('Times','',12);
$pdf->Cell(0,0,'pn',0,1,'L',false);
$pdf->Ln($lineBreak);
$pdf->Ln($lineBreak);
$pdf->SetFont('Times','BU',12);
$pdf->Cell(0,0,'Description:',0,1,'L',false);
$pdf->Ln($lineBreak);
$pdf->SetFont('Times','',12);
$pdf->Cell(0,0,'desc',0,1,'L',false);
$pdf->Ln($lineBreak);
$pdf->SetFont('Times','BU',12);
$pdf->Cell(0,0,'Quantity:',0,1,'L',false);
$pdf->Ln($lineBreak);
$pdf->SetFont('Times','',12);
$pdf->Cell(0,0,'2',0,1,'L',false);
$pdf->Ln($lineBreak);
$pdf->SetFont('Times','BU',12);
$pdf->Cell(0,0,'Order Number:',0,1,'L',false);
$pdf->Ln($lineBreak);
$pdf->SetFont('Times','B',12);
$pdf->Cell(0,0,'no1',0,1,'L',false);
$pdf->Ln($lineBreak);
$pdf->Cell(0,0,'no2',0,1,'L',false);
$pdf->Ln($lineBreak);
$pdf->Ln($lineBreak);
$pdf->SetFont('Times','BU',14);
$pdf->Cell(0,0,'label:',0,1,'C',false);
$pdf->MultiCell(0,0,"A bunch \n of text where line breaking \n does not work",1,'C',false);
$pdf->Output();
?>
显示方式如下:http : //i.imgur.com/qlMrNQs.png
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句