Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
150374 | Jan 4,2020 12:25 AM UTC | Jan 9,2020 07:12 AM UTC | ASP.NET MVC - EJ 2 | 7 |
![]() |
Tags: DocumentEditor |
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";
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.