Created
October 5, 2023 14:02
-
-
Save bjoerntx/96dbe185682061a2b57652e5503ff494 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
[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