Hey there. When I save my document using Control+S, the file gets saved in .sfdt format. I wanted to convert it into .docx format and also push that docx file to a new folder in my existing github repository. Is it possible?
Here is my code !
```
```
|
mounted ()
{
this.$refs.documenteditor.ej2Instances.documentEditor.keyDown = function (args)
{
// debugger;
let keyCode = args.event.which || args.event.keyCode;
let isCtrlKey = (args.event.ctrlKey || args.event.metaKey) ? true : ((keyCode === 17) ? true : false);
let isAltKey = args.event.altKey ? args.event.altKey : ((keyCode === 18) ? true : false);
// 83 is the character code for 'S'
if (isCtrlKey && !isAltKey && keyCode === 83) {
//To prevent default save operation, set the isHandled property to true
args.isHandled = true;
tthis.$refs.documenteditor.ej2Instances.documentEditor.save('sample', 'Docx');
args.event.preventDefault();
} else if (isCtrlKey && isAltKey && keyCode === 83) {
this.$refs.documenteditor.ej2Instances.documentEditor.save('sample', 'Sfdt');
}
}
} |
|
ej.documenteditor.DocumentEditorContainer.Inject(ej.documenteditor.Toolbar); |
I am still not able to convert it into .doc file.
|
<ejs-documenteditorcontainer ref='documenteditorcontainer' id='container' pageOutline='#E0E0E0' style='width: 100%;height: 590px;' :enableToolbar='true' v-bind:keyDown='onKeyDown'></ejs-documenteditorcontainer>
// please give your container reference.
this.$refs.documenteditorcontainer.ej2Instances.documentEditor.keyDown = function (args)
{
//debugger;
let keyCode = args.event.which || args.event.keyCode;
let isCtrlKey = (args.event.ctrlKey || args.event.metaKey) ? true : ((keyCode === 17) ? true : false);
let isAltKey = args.event.altKey ? args.event.altKey : ((keyCode === 18) ? true : false);
// 83 is the character code for 'S'
if (isCtrlKey && !isAltKey && keyCode === 83) {
//To prevent default save operation, set the isHandled property to true
args.isHandled = true;
this.save('sample', 'Docx');
args.event.preventDefault();
} else if (isCtrlKey && isAltKey && keyCode === 83) {
this.save('sample', 'Sfdt');
}
}
|
Hey there Mr Kurthis,
Thanks so much, I am now able to download the docx and sfdt file. One more doubt which I have is that can we save the docx to a folder in the github repository or into firebase(any database) directly rather than saving it into the local storage?
Hey there team,
I tried to integrate the given code to our previous codebase(Vue-sample-save), but was unsuccessful in saving the document to the server. I think it's because there is another folder structure in the asp net core. Could you guys please help me out and implement the "downloading to server feature" in my codebase?
|
document.getElementById('export').addEventListener('click', () => {
let http: XMLHttpRequest = new XMLHttpRequest();
// Run the web service then replace the service URL by running local URL.
http.open('POST', 'http://localhost:5000/api/documenteditor/SaveDocument');
http.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
http.responseType = 'json';
//Serialize document content as SFDT.
let sfdt: any = { content: container.documentEditor.serialize() };
//Send the sfdt content to server side.
http.send(JSON.stringify(sfdt));
});
|
I'm still struggling to integrate it with the previous code (vue-sample-save). Please help me out and do the needful because I have to complete it ASAP.
|
//client side
methods: {
onSave:function() {
let proxy = this;
let http = new XMLHttpRequest();
// Run the web service then replace the service URL by running local URL.
http.open('POST', 'http://localhost:62870/api/documenteditor/SaveDocument');
http.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
http.responseType = 'json';
//Serialize document content as SFDT.
let sfdt = { content: proxy.$refs.doceditcontainer.ej2Instances.documentEditor.serialize()};
//Send the sfdt content to server side.
http.send(JSON.stringify(sfdt));
},
}
mounted() {
document.getElementById('export').addEventListener('click', this.onSave.bind(this));
}
//server side
[AcceptVerbs("Post")]
[HttpPost]
[EnableCors("AllowAllOrigins")]
[Route("SaveDocument")]
public string SaveDocument([FromBody] SaveParameter data)
{
Stream document = WordDocument.Save(data.content, FormatType.Docx);
FileStream file = new FileStream("sample.docx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
document.CopyTo(file);
file.Close();
document.Close();
return "Sucess";
} |
Hey there, I'm having trouble compiling with vue-router
Im getting this error - Module build failed: C:/Users/Adarsh Narayanan/vue-web-doc/src/main.js: Duplicate declaration "SaveDoc"
5 | import SeeDoc from "./components/SeeDoc.vue";
6 |
7 | const SaveDoc = { template: "
" };
| ^
8 | const SeeDoc = { template: "
" };
9 |
10 | const routes = [
@ multi (webpack)-dev-server/client?http://localhost:8080/ webpack/hot/dev-server ./src/main.js
Here are my vue files - https://www.mediafire.com/file/rj2cv6i2vw7nyul/vue-web-doc.rar/file
Thanks in advance for spending your valuable time for me 🙂
Hey team, now I'm getting a new error like this-
/src/main.js
Module not found: Error: Can't resolve './SaveDoc.vue' in 'C:\Users\Adarsh Narayanan\vue-web-doc\src'
@ ./src/main.js 5:0-36
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
Here are the vue 2 files - https://www.mediafire.com/folder/v1fueaustlkzb/vue2-router
Now I'm getting an error like this!
./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/assets/components/SaveDoc.vue
Module build failed: SyntaxError: C:/Users/Adarsh Narayanan/vue-web-doc/src/assets/components/SaveDoc.vue: Unexpected token, expected , (74:7)
72 | Vue.use(ButtonPlugin);
73 | [
> 74 | methods: {
| ^
75 | goBack() {
76 | window.history.length > 1 ? this.$router.go(-1) : this.$router.push("/");
77 | },
@ ./src/assets/components/SaveDoc.vue 8:0-110 9:0-123
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
Here are my files - https://www.mediafire.com/folder/ruvp7zg99zq5u/vue2-webdoc
|
<template>
<div id="app">
<h1>{{ display(message) }}</h1>
</div>
</template>
<script>
export default {
name: 'app',
data() {
return {
message: {
value :'Hello World'
}
};
},
methods: {
display(message) {
return `${message.value}`;
}
}
}
</script>
<style>
</style> |
Hey Kurthis,
That error was solved. Now another error has arrised.
Here is the error:
./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/assets/components/SaveDoc.vue Module build failed: SyntaxError: C:/Users/Adarsh Narayanan/vue-web-doc/src/assets/components/SaveDoc.vue: Unexpected token (230:0) 228 | }; 229 | } > 230 | | ^ @ ./src/assets/components/SaveDoc.vue 8:0-110 9:0-123 @ ./src/main.js @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
Here are my vue-2 files - https://github.com/adarsh-narayanan8/vue2-savedoc
Hey Mr. Kurthis,
Can you help me out ASAP, because I'm reaching the deadline!
Hey Mr. Kurthis,
I want the vue router to Save the Doc and another route to See the Doc.
I was wanting this feature for a long time. What you are giving is just the saving the doc.
Here are my vue 2 router files - https://github.com/Adarsh88/vue-web-doc
Please do the needful and help me out~