Add an image to an existing pdf file with php [closed]

0

Someone has some idea of how to add a signature to an existing pdf file with php. I have a laboratory system where analysis results are stored in pdf format and I need to insert in the file signatures that I have in image format so that the results are valid.

How can it be done?

    
asked by nbrusquetti 26.01.2017 в 14:38
source

2 answers

0

Even though your question requires research work, I'll leave you with an answer because I found your question interesting.

Based on this answer ( Insert images in PDF file using PHP ) ( Insert image files in an existing PDF using PHP ) of SOen and this other link , you can use the following libraries FPDF and FPDI as follows (very simple example):

require_once('fpdf.php'); // Incluímos las librerías anteriormente mencionadas
require_once('fpdi.php'); // Incluímos las librerías anteriormente mencionadas

$pdf = new FPDI();
$pdf->AddPage();
$pdf->setSourceFile("Ruta_de_mi_archivo_PDF"); // Sin extensión
$template = $pdf->importPage(1);
$pdf->useTemplate($template);
$pdf->Image('Ruta_de_mi_imagen.jpg', $x, $y, $width, $height);
$pdf->Output($nuevoNombreDelPDF, "F");

Where the variables $x and $y are the coordinates where to put the image inside your PDF, $width and $height are the width and the height respectively and finally the variable $nuevoNombreDelPDF that will be the name of our "new" PDF

    
answered by 26.01.2017 / 14:59
source
0

You can use the FPDF class for PHP, which is responsible for generating PHP files and the FPDI class that can be used to import files or pages of pre-existing PDF files.

Take a look at this

    
answered by 26.01.2017 в 14:44