Hi there,
I found that when loading/opening a document from my local disk into the document editor, it takes some time, depending on the file size.
If it is a larger file, it will take longer time to load, but if it is a small file, then it will load very fast.
So I wonder if there is any way to make it faster? Maybe like I host it myself, is it possible?
If yes then how can I do it?
|
loadFile(fileName: string) {
var obj = this;
var params = "{fileName: '" + fileName + "'}";
var httpRequest = new XMLHttpRequest();
httpRequest.open('Post', 'http://localhost:62870/api/DocumentEditor/Import?fileName=' + fileName, true);
httpRequest.setRequestHeader("Content-Type", "application/json");
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState === 4) {
if (httpRequest.status === 200 || httpRequest.status === 304) {
//Load Sfdt string in to document editor
obj.container. documentEditor.open(JSON.parse(httpRequest.responseText));
}
else {
// exception
}
}
};
obj.container.documentEditor.documentName = fileName;
httpRequest.send(params);
}
|
|
public string Import (string filename)
{
string path = _hostingEnvironment.ContentRootPath + "\\App_Data\\" + filename + ".docx”.
Stream stream = System.IO.File.OpenRead(path);
stream.Position = 0;
WordDocument document = WordDocument.Load(stream, FormatType.Docx);
string json = Newtonsoft.Json.JsonConvert.SerializeObject(document);
stream.Dispose();
document.Dispose();
return json.
} |