Created
August 25, 2023 14:06
-
-
Save bjoerntx/dac41683a3d6a9793bb0837dcc87e53a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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