Hi,
I am working with digital signature, and in my word document I have multiple places for multiple signatures line need to be signed. And my question is that how could I digital sign for all of them? I try for a loop but just a final signature was signed.
@minhnle I have tested the scenario using the following code and see both signatures in the output document:
// Create a Document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set signature line options.
SignatureLineOptions signatureLineOptions = new SignatureLineOptions
{
Signer = "Entername",
SignerTitle = "QA",
Email = "EnterSomeEmail",
ShowDate = true,
DefaultInstructions = false,
Instructions = "You need more info about signature line",
AllowComments = true
};
// Insert signature line.
SignatureLine signatureLine1 = builder.InsertSignatureLine(signatureLineOptions).SignatureLine;
signatureLine1.ProviderId = Guid.NewGuid();
builder.Writeln();
// Insert another signature line.
SignatureLine signatureLine2 = builder.InsertSignatureLine(signatureLineOptions).SignatureLine;
signatureLine2.ProviderId = Guid.NewGuid();
string outpuFileName = @"C:\Temp\out.docx";
doc.Save(outpuFileName);
Sing(outpuFileName, signatureLine1, "fist signature", CertificateHolder.Create(@"C:\Temp\sign1.pfx", "12345678"));
Sing(outpuFileName, signatureLine2, "second signature", CertificateHolder.Create(@"C:\Temp\sing2.pfx", "87654321"));
private static void Sing(string fileName, SignatureLine signatureLine, string comments, CertificateHolder cert)
{
SignOptions signOptions = new SignOptions();
signOptions.Comments = comments;
signOptions.SignTime = DateTime.Now;
signOptions.SignatureLineId = signatureLine.Id;
signOptions.ProviderId = signatureLine.ProviderId;
DigitalSignatureUtil.Sign(fileName, fileName, cert, signOptions);
}