如何通过onlyOffice在线编辑word
第一步,我们写个简单的html文件,引用本地onlyOffice的js文件,我本地是:http://localhost:8702/web-apps/apps/api/documents/api.js,然后写上网关上相关javascript脚本的内容(手动设置编辑框的高和宽),具体如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript"src="http://localhost:8702/web-apps/apps/api/documents/api.js"></script>
</style>
</head>
<body>
<div id="placeholder"class="nav"></div>
<script language="javascript"type="text/javascript">
new DocsAPI.DocEditor("placeholder",{
"document":{
"fileType":"docx",
"key":"12NAFE",
"title":"test6.docx",
"url":"你需要编辑word文件的url"
},
"documentType":"text",
"width":"1600px",
"height":"900px",
"editorConfig":{
"callbackUrl":"编辑word后保存时回调的地址,这个api需要自己写了,将编辑后的文件通过这个api保存到自己想要的位置"
},
"permissions":{
"comment":true,
"download":true,
"edit":true,(文件是否可以编辑,false时文件不可编辑)
"fillForms":true,
"print":true,
"review":true
}
});
</script>
</body>
</html>
写完html文件后,我们打开