tecnickcom / TCPDF

Official clone of PHP library to generate PDF documents and barcodes
https://tcpdf.org
Other
4.22k stars 1.52k forks source link

Find element and get coordinates #746

Open Kossin7 opened 2 months ago

Kossin7 commented 2 months ago

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);