9

我正在尝试使用 PHP FPDF 库生成 PDF 文档,

我试图在页面上绘制一条水平线,该线在左侧和右侧的缩进量相同。

我很难做到这一点。

我的代码如下,任何帮助将不胜感激。

$pdf = new FPDF( 'P', 'mm', 'A4' );

$pdf->AddPage();
$pdf->SetDisplayMode(real,'default');
$pdf->SetFillColor(0,0,0);
$pdf->SetFont('Arial','B',16);

$pdf->Image('logo.jpg',20,10,50,33.3);

$pdf->SetDrawColor(188,188,188);
$pdf->Line(20,45,150,45);
4

2 回答 2

20

给定一张肖像,A4 页面宽 210 毫米,一些简单的数学运算应该可以帮助您解决这个问题:

$pdf->Line(20, 45, 210-20, 45); // 20mm from each edge
$pdf->Line(50, 45, 210-50, 45); // 50mm from each edge

鉴于您的声明如您在原始问题中所述:

$pdf = new FPDF( 'P', 'mm', 'A4' ); // A4, portrait, measurements in mm.
于 2013-09-10T09:47:25.753 回答
-1

使用以下 -

$pdf = new PDF('P','mm','A4');  //Set PDF as Potrait
$pdf->Ln(4);                    //Break
$pdf->Line(startpoint, 45, endpoint-50, 45);  //Set the line
$pdf->Ln(4); //Break
于 2017-08-05T03:53:55.547 回答