【发布时间】:2018-10-04 09:49:18
【问题描述】:
我正在与 laravel 合作使用 FPDF 制作报告。它运行正常,但每个底部页面的图像都没有正确对齐。我用图像提到了这一点。我该如何解决?我工作了很长时间。这是我的代码。 提前致谢。
public function img_pdf_full()
{
$data= visitor::where('flag', '1')
->orderBy('id', 'desc')
->get();
$pdf = new PDF_Code128(); //'P','mm',array(58,20)
$pdf->AddPage('L');
$pdf->SetFont('Arial','B',16);
$pdf->Cell(0,10,"Visitor's Log",0,0,'C');
$pdf->Ln();
$pdf->SetFont('Arial','B',10);
$pdf->Cell(12,10,'Photo',1,0,'C',0);
$pdf->Cell(40,10,'Name',1,0,'C',0);
$pdf->Cell(20,10,'Visitor ID',1,0,'C',0);
$pdf->Cell(20,10,'Date',1,0,'C',0);
$pdf->ln();
$pdf->SetFont('Arial','',7);
foreach ($data as $v) {
$image1 = public_path('storage/'.$v->v_photo);
$new_date = date("d F, Y", strtotime($v->v_date));
$pdf->Cell(12,10, $pdf->Image($image1, $pdf->GetX(), $pdf->GetY(), 11.5,10) ,1,0,'C',0);
$pdf->Cell(40,10,$v->v_name,1,0,'C',0);
$pdf->Cell(20,10,$v->v_id,1,0,'C',0);
$pdf->Cell(20,10,$new_date,1,0,'C',0);
$pdf->ln();
}
$pdf->ln();
$pdf->Output();
exit;
}
【问题讨论】:
-
当你输入
$pdf->Cell(12,10, $pdf->Image($image1, $pdf->GetX(), $pdf->GetY(), 1,1) ,1,0,'C',0);时会发生什么 -
它运行正常,但每个底部页面的图像都没有正确对齐。我上传了一张图片。这里的图像应该在框中。我该如何解决?