Updating multiple signatures of different types
Leave feedback
GroupDocs.Signature provides different classes of signatures to manipulate them by changing its properties over update method of Signature class. This method returns UpdateResult object to analyze if signatures were successfully processed.
Please be aware that update method modifies the same document that was passed to constructor of Signature class. The UpdateResultcontains list of successfully updated signatures and ones that failed. The signature could be failed to update due to several reasons:
if signature object was initialized with constructor by incorrect signature identifier;
if signature object was not found;
there was an error occurred while updating signature in the document;
the signature type is not supported for modification (Digital, Form Field or Metadata signature).
Here are the steps to update multiple signature in the document with GroupDocs.Signature:
Create new instance of Signature class and pass source document path as a constructor parameter;
Instantiate one or several Search options with desired properties;
Call search method and pass created list of Search Options to obtain list of BaseSignatures;
Select from list BaseSignatures object(s) that should be updated;
Call Signature object update method and pass one or several signatures to it.
Analyze UpdateResult result to check whether signatures were updated or not.
Update multiple signatures of different types in the document
This example shows how to update signature that was found using search method.
// initialize Signature instance
Signaturesignature=newSignature("signed.pptx");// define few search options
BarcodeSearchOptionsbarcodeOptions=newBarcodeSearchOptions();QrCodeSearchOptionsqrCodeOptions=newQrCodeSearchOptions();// add options to list
List<SearchOptions>listOptions=newArrayList<SearchOptions>();listOptions.add(barcodeOptions);listOptions.add(qrCodeOptions);// search for signatures in document
SearchResultresult=signature.search(listOptions);if(result.getSignatures().size()>0){System.out.print("\nTrying to update all signatures...");// mark all signatures as actual Signatures
for(BaseSignaturebaseSignature:result.getSignatures()){baseSignature.setSignature(true);}// update all found signatures
UpdateResultupdateResult=signature.update("signed.pptx",result.getSignatures());if(updateResult.getSucceeded().size()==result.getSignatures().size()){System.out.print("\nAll signatures were successfully updated!");}else{System.out.print("Successfully updated signatures : "+updateResult.getSucceeded().size());System.out.print("Not updated signatures : "+updateResult.getFailed().size());}System.out.print("\nList of updated signatures:");intnumber=1;for(BaseSignaturetemp:updateResult.getSucceeded()){System.out.print("Signature #"+number+++": Type: "+temp.getSignatureType()+" Id:"+temp.getSignatureId()+", Location: "+temp.getLeft()+"x"+temp.getTop()+". Size: "+temp.getWidth()+"x"+temp.getHeight());}}else{System.out.print("No one signature was found.");}}catch(Exceptione){thrownewGroupDocsSignatureException(e.getMessage());}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
Along with full-featured .NET library we provide simple, but powerful free Apps. You are welcome to eSign PDF, Word, Excel, PowerPoint documents with free to use online GroupDocs Signature App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.