GroupDocs.Signature provides BarcodeSignature class to manipulate barcode signatures and delete them from the documents over Delete method. Please be aware that Delete method modifies the same document that was passed to constructor of Signature class.
How to delete Barcode signature from the document
Here are the steps to delete Barcode signature from the document with GroupDocs.Signature:
Create new instance of Signature class and pass source document path as a constructor parameter;
Select from list BarcodeSignature object(s) that should be removed from the document;
Call Signature object Delete method and pass one or several signatures to it.
This example shows how to delete Barcode signature that was found using Search method.
constfilePath=Constants.SAMPLE_PDF_SIGNED;constfileName=path.basename(filePath);constoutputDirectory=path.join(Constants.OutputPath,'DeleteBarcode');if(!fs.existsSync(outputDirectory)){fs.mkdirSync(outputDirectory,{recursive:true});}// Copy source file since the delete method works with the same Document
constoutputFilePath=path.join(outputDirectory,fileName);fs.copyFileSync(filePath,outputFilePath);constsignature=newsignatureLib.Signature(outputFilePath);constoptions=newsignatureLib.BarcodeSearchOptions();// Search for Barcode signatures in the document
constsignatures=signature.search(signatureLib.BarcodeSignature.class,options).toArray();if(signatures.length>0){constbarcodeSignature=signatures[0];constisDeleted=signature.delete(outputFilePath,barcodeSignature);constbarcodeText=barcodeSignature.getText();constencodeTypeName=barcodeSignature.getEncodeType().getTypeName();if(isDeleted){console.log(`Signature with Barcode '${barcodeText}' and encode type '${encodeTypeName}' was successfully deleted from the document '${fileName}'.`);}else{console.log(`Failed to delete the signature! Barcode '${barcodeText}' with encode type '${encodeTypeName}' was not removed from the document '${fileName}'.`);}}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples: