如何通過(guò)onlyOffice在線編輯word
第一步,我們寫個(gè)簡(jiǎn)單的html文件,引用本地onlyOffice的js文件,我本地是:http://localhost:8702/web-apps/apps/api/documents/api.js,然后寫上網(wǎng)關(guān)上相關(guān)javascript腳本的內(nèi)容(手動(dòng)設(shè)置編輯框的高和寬),具體如下:
<!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后保存時(shí)回調(diào)的地址,這個(gè)api需要自己寫了,將編輯后的文件通過(guò)這個(gè)api保存到自己想要的位置"
},
"permissions":{
"comment":true,
"download":true,
"edit":true,(文件是否可以編輯,false時(shí)文件不可編輯)
"fillForms":true,
"print":true,
"review":true
}
});
</script>
</body>
</html>
寫完html文件后,我們打開(kāi)