/**
  * Create the signature.
  *
  * @param SetaPDF_Core_Reader_FilePath $tmpPath
  * @return mixed
  * @throws SetaPDF_Signer_Exception
  */
 public function createSignature(SetaPDF_Core_Reader_FilePath $tmpPath)
 {
     if (!file_exists($tmpPath) || !is_readable($tmpPath)) {
         throw new InvalidArgumentException('Signature template file cannot be read.');
     }
     $hash = $this->_getHash($tmpPath);
     $req = array('signingRequest' => array('ticket' => $this->getTicket(), 'pin' => $this->_pin, 'data' => $hash));
     $client = new SoapClient($this->_wsdl, array_merge($this->_clientOptions, array('trace' => true)));
     $result = $client->signDigest($req);
     $this->_lastResult = $result;
     if ($result->return->result != 0) {
         throw new SetaPDF_Signer_Exception(sprintf('QuoVadis signDigest failed with result code %s.', $result->return->result));
     }
     $signature = $result->return->signature;
     if ($this->_collectVerificationData) {
         $req = array('verifyingRequest' => array('ticket' => $this->getTicket(), 'data' => $hash, 'signature' => $signature));
         $verificationData = $client->verifyDigest($req)->return;
         if ($verificationData->result != 0) {
             throw new SetaPDF_Signer_Exception(sprintf('QuoVadis verifyDigest failed with result code %s.', $verificationData->result));
         }
         $this->_verificationData = $verificationData;
     }
     return $signature;
 }