TCPDF icon indicating copy to clipboard operation
TCPDF copied to clipboard

Find element and get coordinates

Open Kossin7 opened this issue 5 months ago • 0 comments

Hello! I need to insert an image at a specific location Is it possible to find an element by text and get its coordinates in order to insert an image in the right place based on them?

use setasign\Fpdi\Tcpdf\Fpdi;
$pdf = new Fpdi();
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->AddPage();
$pdf->setSourceFile(base_path().'/10147.pdf');

$tplId = $pdf->importPage(1);
$pdf->useTemplate($tplId, 0, 0);

// Example code: 
// search element by text
// $el = $pdf->findByText('SomeText');
//$pdf->Image(base_path().'/pechat.png', $el ->getX() + 40, $el ->getY() + 40 , 35, 35, 'PNG', '', '', true);

Kossin7 avatar Sep 11 '24 06:09 Kossin7