Created
January 6, 2016 17:12
-
-
Save bjoerntx/7d25d164005185150a7d 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 LoadTemplate(LoadDocumentViewModel model) | |
{ | |
byte[] data; | |
using (TXTextControl.ServerTextControl tx = | |
new TXTextControl.ServerTextControl()) | |
{ | |
tx.Create(); | |
TXTextControl.StreamType streamType = | |
TXTextControl.StreamType.WordprocessingML; | |
switch(Path.GetExtension(model.DocumentName)) | |
{ | |
case ".doc": | |
streamType = TXTextControl.StreamType.MSWord; | |
break; | |
case ".rtf": | |
streamType = TXTextControl.StreamType.RichTextFormat; | |
break; | |
case ".tx": | |
streamType = TXTextControl.StreamType.InternalUnicodeFormat; | |
break; | |
case ".pdf": | |
streamType = TXTextControl.StreamType.AdobePDF; | |
break; | |
} | |
tx.Load(Server.MapPath("/App_Data/documents/" + | |
model.DocumentName), streamType); | |
tx.Save(out data, | |
TXTextControl.BinaryStreamType.InternalUnicodeFormat); | |
} | |
return Convert.ToBase64String(data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment