Created
March 1, 2017 21:19
-
-
Save bjoerntx/6400f3d6f20aba64d34c6b6141ae09d1 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 string InsertSubTextPart(string Name, string BinaryDocument, bool Protected) | |
{ | |
byte[] data = null; | |
// create a temporary ServerTextControl to create the | |
// SubTextPart | |
using (ServerTextControl tx = new ServerTextControl()) | |
{ | |
tx.Create(); | |
// load the Selection from the Web.TextControl | |
tx.Load(Convert.FromBase64String(BinaryDocument), | |
BinaryStreamType.InternalUnicodeFormat); | |
tx.SelectAll(); | |
int iTextLength = tx.Selection.Length; | |
// create a new SubTextPart over the complete text | |
SubTextPart part = new SubTextPart("txmb_" + Name, | |
Convert.ToInt32(Protected), 1, iTextLength); | |
tx.SubTextParts.Add(part); | |
// save the complete document | |
tx.SelectAll(); | |
tx.Selection.Save(out data, BinaryStreamType.InternalUnicodeFormat); | |
} | |
// return the Selection as a Base64 encoded string | |
return Convert.ToBase64String(data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment