Discuss this help topic in SecureBlackbox Forum

Sign existing signature line

To sign an existing signature line you need to

  1. create an instance of TElOfficeOpenXMLSignatureHandler class and add it to the document using AddSignature() method of the document object
  2. use TElOfficeOpenXMLDocument.SignatureLineCount property to get the number of signature lines, then use TElOfficeOpenXMLDocument.SignatureLines[] property to choose the needed signature line
  3. assign the handler to the signature line using line's TElOfficeOpenXMLSignatureLine.SignatureHandler property
  4. configure signature-released properties of the handler, such as SignatureInfoV1, signature line or XAdES info
  5. call Sign() method to sign, after that close the document to flush changes

C#:


TElOfficeOpenXMLSignatureHandler OpenXMLSigHandler = new TElOfficeOpenXMLSignatureHandler();
Document.AddSignature(OpenXMLSigHandler, true);

OpenXMLSigHandler.AddDocument();
if (Document.OpenXMLDocument.SignatureLineCount > 0)
    Document.OpenXMLDocument.get_SignatureLines(0).SignatureHandler = OpenXMLSigHandler;

OpenXMLSigHandler.Sign(certificate);
Delphi:

OpenXMLSigHandler := TElOfficeOpenXMLSignatureHandler.Create(nil);
Document.AddSignature(OpenXMLSigHandler, True);

OpenXMLSigHandler.AddDocument();
if Document.OpenXMLDocument.SignatureLineCount > 0 then
  Document.OpenXMLDocument.SignatureLines[0].SignatureHandler := OpenXMLSigHandler;

OpenXMLSigHandler.Sign(Certificate);

How To articles about MS Office OpenXML documents

Discuss this help topic in SecureBlackbox Forum