Last active
October 14, 2023 04:56
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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