removeAllSignatures method

removeAllSignatures(srcStream, dstStream)

Removes all digital signatures from document in source stream and writes unsigned document to destination stream. Output will be written to the start of stream and stream size will be updated with content length.

The following formats are compatible for digital signature removal: LoadFormat.Doc, LoadFormat.Dot, LoadFormat.Docx, LoadFormat.Dotx, LoadFormat.Docm, LoadFormat.Odt, LoadFormat.Ott.

removeAllSignatures(srcStream: Buffer, dstStream)
ParameterTypeDescription
srcStreamBuffer
dstStream

removeAllSignatures(srcFileName, dstFileName)

Removes all digital signatures from source file and writes unsigned file to destination file. The following formats are compatible for digital signature removal: LoadFormat.Doc, LoadFormat.Dot, LoadFormat.Docx, LoadFormat.Dotx, LoadFormat.Docm, LoadFormat.Dotm, LoadFormat.Odt, LoadFormat.Ott.

removeAllSignatures(srcFileName: string, dstFileName: string)
ParameterTypeDescription
srcFileNamestring
dstFileNamestring

Examples

Shows how to remove digital signatures from a digitally signed document.

// There are two ways of using the DigitalSignatureUtil class to remove digital signatures
// from a signed document by saving an unsigned copy of it somewhere else in the local file system.
// 1 - Determine the locations of both the signed document and the unsigned copy by filename strings:
aw.DigitalSignatures.DigitalSignatureUtil.removeAllSignatures(base.myDir + "Digitally signed.docx",
  base.artifactsDir + "DigitalSignatureUtil.LoadAndRemove.FromString.docx");

// 2 - Determine the locations of both the signed document and the unsigned copy by file streams:
let streamIn = base.loadFileToBuffer(base.myDir + "Digitally signed.docx");
let streamOut = fs.createWriteStream(base.artifactsDir + "DigitalSignatureUtil.LoadAndRemove.FromStream.docx");

aw.DigitalSignatures.DigitalSignatureUtil.removeAllSignatures(streamIn, streamOut);
await new Promise(resolve => streamOut.on("finish", resolve));

// Verify that both our output documents have no digital signatures.
expect(aw.DigitalSignatures.DigitalSignatureUtil.loadSignatures(base.artifactsDir + "DigitalSignatureUtil.LoadAndRemove.FromString.docx").count).toEqual(0);
expect(aw.DigitalSignatures.DigitalSignatureUtil.loadSignatures(base.artifactsDir + "DigitalSignatureUtil.LoadAndRemove.FromStream.docx").count).toEqual(0);

See Also