[英]Align the text in pdf correctly using fpdf
我必須創建一個pdf file
。 我正在使用fpdf 。 我的 pdf 文件應該是這樣的:
This is a sample pdf.
Hello world.
sample text sample text.
但是這些行以不希望的方式顯示。
我的代碼是
require('fpdf.php');
$pdf = new FPDF('P','mm','A4');
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(0,10,'This is a sample pdf.');
$pdf->Cell(0,30,'Hello world.');
$pdf->Cell(0,50,'sample text sample text.');
$pdf->Output();
結果 pdf 如下所示:
如何正確對齊pdf中的文本?
Cell(float w [, float h [, string txt [, mixed border [, int ln [, string align [, boolean fill [, mixed link]]]]]]])
調用后,當前位置向右移動或移動到下一行。
ln指示調用后當前位置應該去哪里。 可能的值為:
0: to the right 1: to the beginning of the next line 2: below
放 1 等價於放 0 並在之后調用 Ln()。 默認值:0。
嘗試這個:
$pdf->Cell(0,10,'This is a sample pdf.', 0, 1);
^ no border
^ after the call move to beginning of next line
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.