Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Signing PDF with SecurSign

 
vivien siu
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, I need to sign my pDF files using SecurSign, I have never did this before, would really appretiate any help given on this.

Thanks!!
 
vivien siu
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello guys, I use the following code to execute SecurSign batch file :
public boolean secursignEncryption(String filePath, String accessID) {
boolean status = false;
String newFile = filePath.replaceAll("_c", "_e");

System.out.println(newFile);

String cmd = "e:\\Appligent\\SecurSign\\secursign -p -encrypt -ownerpass estatement -userpass 654321 -nomodify -nocopy -nonotes -noaccess -noassembly -nofill -o ";
cmd = cmd + newFile + " " + filePath;
cmd = cmd.replaceAll("-userpass 654321", "-userpass " +
accessID.trim());

System.out.println(cmd);

status = runExternal(cmd);

return status;
}

public boolean runExternal(String path) {
boolean execute = false;
try {
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(path);
InputStream in = p.getInputStream();
OutputStream out = p.getOutputStream();
InputStream err = p.getErrorStream();
execute = true;
} catch (IOException e) {
e.printStackTrace();
}
return execute;
}


and I got this exception instead:


AFAIK the error=2 means that the file is not found, but I have specified the exact file path, can anyone tell me what is wrong actually?
 
vivien siu
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, I solved the error. The correct code should be:

I didn't add the .bat extension

Although there are no errors now, SecurSign is not creating a new file for me in the specified new file path. Can anyone tell me how I should write the command so that SecurSign will take an old file, encrypt it with password, and save the encrypted file to a new location, which the encrypted file is not previously created before?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the command work correctly on the command-line? Runtime.exec has some issues one needs to be aware of.
 
vivien siu
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmmm... solved the problem finally!

2 interesting things:
1. Secursign only works with PDF files. Previously I was testing using txt files
2. Even if it is a PDF file I'm using, if the path is too long, the command wouldn't work either. The command for SecurSign to run itself is already very long. I suggest that you put it under c: or e: what ever, then at most only make a folder and cram all the PDFs in there.

Anyway thanks Ulf
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic