I have this script which already sign a PDF
<?php
require("../config/include.php");
require_once(DIR_LIBRERIAS."TCPDF/tcpdf.php");
require_once(DIR_LIBRERIAS.'FPDI/fpdi.php');
//$pdf = new TCPDF(PDF_PAGE_ORIENTATION);
error_reporting(0);
// set certificate file
$certificate = 'file://'.DIR_ROOT.'cert/testcertif.crt';
$pdf = new FPDI();
$filename = "zz_test_firmado.pdf";
$info = array('Name' => 'testcertif', 'Location' => 'Oficina', 'Reason' => 'test firma', 'ContactInfo' => 'test.com.ar');
$pdf->setSignature($certificate, $certificate, 'test key pass', '', 2, $info);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pages_count= $pdf->setSourceFile($filename);
$page = "P";
for($i = 1; $i <= $pages_count; $i++)
{
$tplIdx = $pdf->importPage($i);
$size = $pdf->getTemplateSize($tplIdx);
if ($size['w'] > $size['h']) {
$pdf->AddPage('L', array($size['w'], $size['h']));
$arrayUltimo = array($size['w'], $size['h']);
$page = "L";
} else {
$pdf->AddPage('P', array($size['w'], $size['h']));
$arrayUltimo = array($size['w'], $size['h']);
}
$pdf->useTemplate($tplIdx, 0, 0, 0, 0, true);
}
$pdf->output('testfirmass222.pdf', 'I');
?>
However, when the pdf that i'm importing already has a signature, the signature is replaced by the new one put on the script, is there a way to keep both?
FPDI does not modify an original but you create a completely new one by importing page appearances of existing documents into a reusable structure.
The resulting document is a completely new one which may look identically but its internal structure is a completely different one.
Annotations and for sure digital signatures will not be imported.
Your task cannot be done with FPDI.
PS: In any case update FPDI to its latest version. It looks like you are using a legacy version.