PDF Signatures with Aloaha and PHP
The Aloaha digital Signature API is implemented as an automation compatible COM Object. That allows virtually all known languages to use the signature API. Please find below some sample source code in PHP.
A valid Aloaha Enterprise License is required to use the Aloaha Signature API. Please contact our support at aloaha@wrocklage.de for an evaluation key.
<?php
$reason = "Signed by Aloaha PDF Suite";
$location= "Ibbenbueren, Germany";
$cert="0";
$image = "c:\\test2\\signature.jpg";
$px1 = 2;
$py1 = 98;
$px2 = 20;
$py2 = 93;
$zero=0;
$api = new COM("aloahapdf.edit");
$infile = "c:\\test2\\test.pdf";
$outfile = "c:\\test2\\test.pdf";
$api->set_unique($cert);
$test = $api->sign_pdf_file($infile, $outfile, $zero, $zero, $px1, $py1, $px2, $py2, $reason, $location, $cert, $image);
$api = NULL;
?>
The variable
cert contains a reference to the certificate to be used. It can contain the path to a PFX file (without password), it can contain a UniqueContainerName or Serialnumber of the Certificate in the Windows Certificate Store or it can contain number 0-9 for cardreaders 0-9 in case a native supported card is used.
The most common problem of NOT getting this code to work is a wrongly configured Webserver. Please make sure that:
- the Webserver process as full access to the Aloaha directory (incl. subdirectories)
- that the Webserver properly unloads Objects. Per default IIS caches Objects even if you unload them. This results in unpredictable results such as no access to the private key.
Please have a look at the document below to find a sample IIS configuration.
Configure IIS Application Pool to use Aloaha Signature API from ASP.pdf (446,62 KB)
Aloaha Software / Knowledge Base / PDF SDK / PDF Signature API / PHP Signature Sample