Skip to content

Instantly share code, notes, and snippets.

How to Digitally Sign a Word Document using Java. For further details: https://kb.aspose.com/words/java/how-to-digitally-sign-a-word-document-using-java/
import com.aspose.words.*;
public class Main
{
public static void main(String[] args) throws Exception // Sign a word document in Java
{
// Set the licenses
new License().setLicense("License.lic");
// Create digital signature options
SignOptions options = new SignOptions();
// Set comments
options.setComments("Signing Authority Comments");
// Set signature time
options.setSignTime(new java.util.Date());
// Create a certificate holder
CertificateHolder certificate = CertificateHolder.create("certificate.pfx", "mypass");
// Sign the document
DigitalSignatureUtil.sign("Document.docx","SignedDocument.docx",certificate,options);
System.out.println("Done");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment