-
-
Save bjoerntx/8b111d5fc1470808755374025f17289a 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
[HttpPost] | |
public IActionResult HandleSignature([FromBody] SignatureData data) { | |
byte[] bPDF; | |
// create temporary ServerTextControl | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { | |
tx.Create(); | |
// load the document | |
tx.Load(Convert.FromBase64String(data.SignedDocument.Document), | |
TXTextControl.BinaryStreamType.InternalUnicodeFormat); | |
X509Certificate2 cert = new X509Certificate2("App_Data/textcontrolself.pfx", "123"); | |
var signatureFields = new List<DigitalSignature>(); | |
foreach (SignatureBox box in data.SignatureBoxes) { | |
signatureFields.Add(new DigitalSignature(cert, null, box.Name)); | |
} | |
TXTextControl.SaveSettings saveSettings = new TXTextControl.SaveSettings() { | |
CreatorApplication = "Your Application", | |
SignatureFields = signatureFields.ToArray() | |
}; | |
// store the PDF in the database or send it to the client | |
tx.Save(out bPDF, TXTextControl.BinaryStreamType.AdobePDFA, saveSettings); | |
// alternatively, save the PDF to a file | |
tx.Save("App_Data/signed.pdf", TXTextControl.StreamType.AdobePDFA, saveSettings); | |
} | |
// return any value to the client | |
return Ok(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment