public HttpResponseMessage ImportFileURL([FromBody]FileUrlInfo param)
{
try
{
using (WebClient client = new WebClient())
{
MemoryStream stream = new MemoryStream(client.DownloadData(param.fileUrl));
Syncfusion.EJ2.DocumentEditor.WordDocument document = Syncfusion.EJ2.DocumentEditor.WordDocument.Load(stream, Syncfusion.EJ2.DocumentEditor.FormatType.Docx);
string json = Newtonsoft.Json.JsonConvert.SerializeObject(document);
document.Dispose();
stream.Dispose();
return new HttpResponseMessage() { Content = new StringContent(json, Encoding.UTF8, "text/plain") };
}
}
catch (Exception ex)
{
return new HttpResponseMessage() { Content = new StringContent("", Encoding.UTF8, "text/plain") };
}
} |
[HttpGet]
public string OpenWord(string fileName)
{
//var path = Constantes.Coucher_no_Auth + fileName;
try
{
using (WebClient client = new WebClient())
{
MemoryStream stream = new MemoryStream(client.DownloadData(fileName));
WordDocument document = WordDocument.Load(stream, FormatType.Docx);
string json = Newtonsoft.Json.JsonConvert.SerializeObject(document);
document.Dispose();
stream.Dispose();
return json;
//var st = new StringContent(json, Encoding.UTF8, "text/plain");
//return new HttpResponseMessage() { Content = st };
}
}
catch (Exception)
{
return "Failure";
}
} |