Sign and verify documents with GroupDocs.Signature
Leave feedback
On this page
GroupDocs.Signature applies electronic signatures to a document and finds them again afterwards. It supports text, image, digital certificate, barcode, QR-code, stamp, metadata and form-field signature types across Word, PDF, Excel, PowerPoint and image formats.
The three examples below cover the full lifecycle: sign, sign again, search.
Sign a document with a text signature
A text signature draws text onto the page at a position you choose. setLeft/setTop place it, setWidth/setHeight bound it.
A QR-code signature encodes arbitrary text — an approval id, a verification URL — into a scannable code placed on the page. Set setEncodeType to the encoding you want; QrCodeTypes.QR is the standard one.
importcom.groupdocs.signature.Signature;importcom.groupdocs.signature.domain.qrcodes.QrCodeTypes;importcom.groupdocs.signature.options.sign.QrCodeSignOptions;Signaturesignature=newSignature("contract.docx");QrCodeSignOptionssignOptions=newQrCodeSignOptions("Approved by John Smith");signOptions.setEncodeType(QrCodeTypes.QR);signOptions.setLeft(100);signOptions.setTop(100);signOptions.setWidth(120);signOptions.setHeight(120);signature.sign("signature-sign-with-qr-code.docx",signOptions);
contract.docx is the sample file used in this example. Click here to download it.
Searching answers “what is on this document?”. It returns every signature of the type you ask for, with its text and encoding.
importcom.groupdocs.signature.Signature;importcom.groupdocs.signature.domain.qrcodes.QrCodeTypes;importcom.groupdocs.signature.domain.signatures.QrCodeSignature;importcom.groupdocs.signature.options.search.QrCodeSearchOptions;importcom.groupdocs.signature.options.sign.QrCodeSignOptions;importjava.util.List;// Sign first, so there is something to find
Signaturesignature=newSignature("contract.docx");QrCodeSignOptionssignOptions=newQrCodeSignOptions("Approved by John Smith");signOptions.setEncodeType(QrCodeTypes.QR);signOptions.setLeft(100);signOptions.setTop(100);signature.sign("signature-search.docx",signOptions);// Now search the signed document
Signaturesearcher=newSignature("signature-search.docx");QrCodeSearchOptionssearchOptions=newQrCodeSearchOptions();List<QrCodeSignature>signatures=searcher.search(QrCodeSignature.class,searchOptions);System.out.println("Signatures found: "+signatures.size());for(QrCodeSignatureqrSignature:signatures){System.out.println("Text: "+qrSignature.getText());}
contract.docx is the sample file used in this example. Click here to download it.
GroupDocs.Signature also applies digital certificate signatures, image and stamp signatures, metadata and form-field signatures; verifies a document against expected signature values; and updates or deletes signatures already present.