GroupDocs.Signature provides the ImageSignature class to manipulate image signatures’ location, size, and textual content. Please note that the Update method modifies the same document that was passed to the constructor of the Signature class.
Here are the steps to update an Image signature in the document with GroupDocs.Signature:
Create a new instance of the Signature class and pass the source document path as a constructor parameter.
Select from the list the ImageSignature object(s) that should be updated.
Call the Signature object’s Update method and pass one or several signatures to it.
This example shows how to update an Image signature that was found using the Search method.
// The path to the documents directory.constfilePath=Constants.SAMPLE_SIGNED_MULTI;constfileName=path.basename(filePath);// Copy source file since the update method works with the same documentconstoutputFilePath=path.join(Constants.OutputPath,'UpdateImage',fileName);constdir=path.dirname(outputFilePath);if(!fs.existsSync(dir)){fs.mkdirSync(dir,{recursive:true});}// Initialize Signature instanceconstsignature=newsignatureLib.Signature(filePath);// Initialize ImageSearchOptionsconstoptions=newsignatureLib.ImageSearchOptions();// Search for image signatures in the documentconstsignatures=signature.search(signatureLib.ImageSignature.class,options).toArray();if(signatures.length>0){constimageSignature=signatures[0];imageSignature.setLeft(100);imageSignature.setTop(100);// Update the image signature in the documentconstresult=signature.update(outputFilePath,imageSignature);if(result){console.log(`\nImagesignatureatlocation${imageSignature.getLeft()}x${imageSignature.getTop()}andSize${imageSignature.getSize()}wasupdatedinthedocument[${fileName}].`);}else{console.log(`\nSignaturewasnotupdatedinthedocument!Imagesignatureatlocation${imageSignature.getLeft()}x${imageSignature.getTop()}andSize${imageSignature.getSize()}wasnotfound!`);}}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in ourΒ GitHub examples: