Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created February 6, 2024 10:56
Show Gist options
  • Save bjoerntx/d2296927bb2dacdd20815b547c1f7b71 to your computer and use it in GitHub Desktop.
Save bjoerntx/d2296927bb2dacdd20815b547c1f7b71 to your computer and use it in GitHub Desktop.
[JSInvokable("LoadDocumentFromFile")]
public void LoadDocumentFromFile(string filename)
{
// check if the file exists
if (!System.IO.File.Exists(filename))
{
return;
}
// load the file into a byte array
byte[] bDocument = System.IO.File.ReadAllBytes(filename);
SignatureSettings signatureSettings = new SignatureSettings()
{
OwnerName = "John Doe",
RedirectUrlAfterSignature = this.BasePath + "Signature/SignDocument",
UniqueId = Guid.NewGuid().ToString(),
SignerName = "Jane Doe",
SignatureBoxes = new SignatureBox[]
{
new SignatureBox("txsign")
{
Style = SignatureBox.SignatureBoxStyle.Signature
}
},
ShowSignatureBar = true
};
// invoke the JS function 'loadDocument' to load back to the modified document
_txdocumentviewer?.InvokeVoidAsync("loadDocument", new object[] { Convert.ToBase64String(bDocument), filename, BasePath, signatureSettings });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment