Mapping signature image to ACORD FORM

In most of the ACORD forms we’ve Authorized signature box in which we fill the name of some Authorized person and we can also map the signature image of the person along with the text name of the authorized person.

To map the image we first create a PDF of image and place the signature image at the required position (position depends upon the ACORD form) in the PDF. After converting the image to PDF we merge both the PDFs (Image PDF and already mapped ACORD FORM pdf) using PDFtk’s multistamp signal command and to resize and make some change in the signature image we need to use “Imagick” library that needs to be install in the system.

Steps to map an image signature to a ACORD FORM.

$mod_image = new Imagick($tmpName);
$mod_image->whiteThresholdImage("rgb(150,150,150)");
$mod_image->setImageFormat("png");
$mod_image->autoLevelImage();
$mod_image->transparentPaintImage("rgb(255,255,255)",0,100,false);
 
$mod_image->trimImage(0.3);
$mod_image->despeckleimage();
 
$mod_image->scaleImage(1800, 300, true);
$signature_image = $mod_image->getImageBlob();

$composite_image = new Imagick();
$composite_image->newImage(3000,300,new ImagickPixel('transparent'));

$pdf_image = new Imagick();   
$composite_image->compositeImage($mod_image,imagick::COMPOSITE_COPY,0,0);
$pdf_image->addImage($composite_image);
$pdf_image->setImageFormat("pdf");

$pdf_image->resetImagePage("5950x8420+4000+550");
// For ACORD 0025 2016-03 Acroform.pdf, this position can be different for each ACORD Form.
$signature_path = sys_get_temp_dir().'/signature_'.$unique.'.pdf';
$pdf_image->writeImages($signature_path,true);
$newpath = sys_get_temp_dir().'/signed_pdf.pdf';
$fullPath = sys_get_temp_dir()."/flattern_pdf.pdf";
$t= exec("pdftk ".$fullPath." multistamp ".$signature_path." output ".$newpath);

// $newpath variable holds the address of signed Flattern PDF.