-
-
Save bjoerntx/2ed6ca4584ba89539e6b8b8cb17d35ff 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
[CustomActionFilter] | |
[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); | |
//FlattenFormFields(tx); | |
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