Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created August 25, 2023 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/dac41683a3d6a9793bb0837dcc87e53a to your computer and use it in GitHub Desktop.
Save bjoerntx/dac41683a3d6a9793bb0837dcc87e53a to your computer and use it in GitHub Desktop.
@using TXTextControl.Web.MVC.DocumentViewer
@{
byte[] documentArray;
List<SignatureBox> signatureBoxes = new List<SignatureBox>();
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
tx.Create();
tx.Load("App_Data\\template.docx", TXTextControl.StreamType.WordprocessingML);
// loop through all signature fields and set the signer data
foreach (TXTextControl.SignatureField field in tx.SignatureFields)
{
var signerData = field.SignerData;
field.SignerData = new TXTextControl.SignerData(field.SignerData.Name,
field.SignerData.Title,
"Test",
field.SignerData.ContactInfo,
"Contract verification");
// add a signature box to the document viewer
signatureBoxes.Add(new SignatureBox(field.Name) { SigningRequired = true, Style = SignatureBox.SignatureBoxStyle.Signature });
}
// save the document
tx.Save(out documentArray, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
}
}
@Html.TXTextControl().DocumentViewer(settings => {
settings.DocumentData = Convert.ToBase64String(documentArray);
settings.SignatureSettings = new SignatureSettings() {
ShowSignatureBar = true,
OwnerName = "Josh Jackson",
SignerName = "Tim Typer",
SignerInitials = "TT",
UniqueId = "12345-12345-12345-12345",
RedirectUrlAfterSignature = this.Url.Action(
"HandleSignature",
"Signature",
null,
Context.Request.Scheme,
null),
SignatureBoxes = signatureBoxes.ToArray()
};
}).Render()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment