@@ -25,8 +25,12 @@ public function sign(JSignParam $params)
2525 $ this ->validation ($ params );
2626
2727 $ commandSign = $ this ->commandSign ($ params );
28- $ output = exec ($ commandSign );
29- $ isSigned = $ output == 'INFO Finished: Signature succesfully created. ' ;
28+ $ out = exec ($ commandSign , $ output );
29+ if (is_array ($ output ))
30+ $ output = $ output [count ($ output ) -1 ];
31+
32+ $ messageSuccess = "INFO Finished: Signature succesfully created. " ;
33+ $ isSigned = ($ output == $ messageSuccess || $ out == $ messageSuccess );
3034 $ this ->throwIf (!$ isSigned , "Error to sign PDF. $ output " );
3135
3236 $ fileSigned = $ this ->fileService ->contentFile (
@@ -43,6 +47,7 @@ public function sign(JSignParam $params)
4347 } catch (Throwable $ e ) {
4448 if ($ params ->getTempPath ())
4549 $ this ->fileService ->deleteTempFiles ($ params ->getTempPath (), $ params ->getTempName ());
50+
4651 throw new Exception ($ e ->getMessage ());
4752 }
4853 }
@@ -55,7 +60,7 @@ private function validation(JSignParam $params)
5560 $ this ->throwIf (empty ($ params ->getPassword ()), 'Certificate Password is Empty. ' );
5661 $ this ->throwIf (!$ this ->isPasswordCertificateValid ($ params ->getCertificate (), $ params ->getPassword ()), 'Certificate Password Invalid. ' );
5762 if ($ params ->isUseJavaInstalled ()) {
58- $ javaVersion = exec ("java -version 2>&1 " );
63+ $ javaVersion = exec ("java -version 2>&1 " );
5964 $ hasJavaVersion = strpos ($ javaVersion , 'not found ' ) === false ;
6065 $ this ->throwIf (!$ hasJavaVersion , 'Java not installed, set the flag "isUseJavaInstalled" as false or install java. ' );
6166 }
0 commit comments