如何通過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文件后,我們打開