Hi
I using WebViewer 10.3.0 to edit docx files. I load document docx from my own serwer. After edit docx i want to save changed document to loaded document on the serwer ( not a local computer). This mean i use :
initialDoc: ‘ocx/tmp/test.docx’
and a want save changest to ocx/tmp/test.docx .
How can i do this?
My code below :
var $j = jQuery.noConflict();
$j(document).ready(function () {
var obj = document.getElementById(‘viewer’);
WebViewer({
path: ‘WebViewer/lib’,
initialDoc: 'ocx/tmp/test.docx', // You can also use documents on your server
enableOfficeEditing: true,
}, document.getElementById('viewer'))
.then(instance => {
const { documentViewer, annotationManager } = instance.Core;
const Tools = instance.Core.Tools;
const Annotations = instance.Core.Annotations;
documentViewer.addEventListener('documentLoaded', () => {
});
});
});
I find another solusion. Add custom button and write code to get edited docx file and convert it to base64 string. In this way i can send this file to server-side.
Thanks for replay.
Your idea is good way. But in additionaly i need get content of file in javascript. I need a way or function in what i get doxc file in bytes for example :
val fileInArrayBytesAfterChanges = instance.UI.anyfunction()
or directly in javascript. This means reading the contents of the downloaded to local storage docx file, but I think this is impossible due to security policy
i want to sent blob file in my api for save after changes so how can i achive this
my current code is
onClick: async () => {
// save the annotations
const xfdfString = await annotationManager.exportAnnotations({
widgets: false,
links: false,
//fields: false
});
console.log(“xfdfStringxfdf String”, xfdfString);
const doc = documentViewer.getDocument();
const data = await doc.getFileData({
// saves the document with annotations in it
xfdfString,
});
const arr = new Uint8Array(data);
const blob = new Blob([arr], { type: “text/plain” });
iwant blob as plain text to give it in my api request data