Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created October 5, 2023 14:02
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/96dbe185682061a2b57652e5503ff494 to your computer and use it in GitHub Desktop.
Save bjoerntx/96dbe185682061a2b57652e5503ff494 to your computer and use it in GitHub Desktop.
[JSInvokable("ProcessDocument")]
public void ProcessDocument(string document)
{
byte[] bDocument;
// create a ServerTextControl instance to load the saved document
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
tx.Create();
tx.Load(Convert.FromBase64String(document), TXTextControl.BinaryStreamType.InternalUnicodeFormat);
// add additional text to the document
tx.Selection.Text = "This document has been modified by .NET\r\n";
// save back
tx.Save(out bDocument, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
}
// invoke the JS function 'loadDocument' to load back to the modified document
_txtextcontrol.InvokeVoidAsync("loadDocument", Convert.ToBase64String(bDocument));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment