0
I dynamically send to this file via controller the data in an array called $vaccines, I am using Import Autoload for this reason. It turns out that the information is being printed in the same place:
<?php
use setasign\Fpdi\Fpdi;
require_once 'vendor/autoload.php';
$pdf = new Fpdi();
$pdf->AddPage('L');
$pdf->setSourceFile("report/cartaoFront.pdf");
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, 5, 5, 290);
/**
* Dados animal
*/
$pdf->addPage('L');
$pdf->setSourceFile("report/cartaoVerso.pdf");
$tplId = $pdf->importPage(1);
$pdf->useTemplate($tplId, 5, 5, 290);
$pdf->SetFont('Arial','',10);
foreach ($vacinas as $item)
{
$pdf->SetTextColor(255, 0, 0);
// Nome Vacina
$pdf->SetXY(12, 35);
$pdf->Cell(5,0,$item['titulo_vacina'],0,1,"C");
// Nome Méd Veterinário
$pdf->SetXY(68, 35);
$pdf->Cell(5,0,utf8_decode($item['nome_veterinario']),0,1,"C");
}
$pdf->Output();
And I need you to enter the information below each one. I tried using $pdf->gety() * 2 but it spaces a lot, also tried using for only it ends up printing 2 or how many data return in the same field.
What I want to solve with this doubt: Make the foreach not repeat the data in the same location but each interaction increment (+ the value of the previous y)
I tried so: $pdf->SetXY(68, 35 + ($pdf->getY();
but it didn’t work either.