美文网首页
onlyoffice pc在线预览word各种文件

onlyoffice pc在线预览word各种文件

作者: 小北呀_ | 来源:发表于2022-12-14 10:14 被阅读0次
    官网

    举例word.html

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <script type="text/javascript" src="http://XXX自己服务器下的地址XXXX/web-apps/apps/api/documents/api.js"></script>
            </style>
        </head>
        <body style="height: 100vh;">
            <div id="placeholder" style="height: 100%; width: 100%;"></div>
            <script language="javascript" type="text/javascript">
                function getQueryVariable(variable) {
                    var query = window.location.search.substring(1);
                    var vars = query.split("&");
                    for (var i = 0; i < vars.length; i++) {
                        var pair = vars[i].split("=");
                        if (pair[0] == variable) {
                            return pair[1];
                        }
                    }
                    return (false);
                }
                // alert(getQueryVariable('url'));
                new DocsAPI.DocEditor("placeholder", {
                    "document": {
                        "fileType": "docx",
                        //"key": "12NAFE",
                        "title": "预览.docx",
                        // "url": "http://xxxxxxxxx.xls"
                        "url": getQueryVariable('url'),
                    },
                    "documentType": "text",
                    "width": "100%",
                    "height": "100%",
                    "editorConfig": {
                        "lang":"zh-CN",
                        // "callbackUrl": "编辑word后保存时回调的地址,这个api需要自己写了,将编辑后的文件通过这个api保存到自己想要的位置"
                    },
                    "permissions": {
                        "comment": true,
                        "download": true,
                        "edit": true,
                        "fillForms": true,
                        "print": true,
                        "review": true
                    }
                });
            </script>
        </body>
    </html>
    
    最重要的是服务器下的地址,后端人员也需要配合启动应用才能使用
            <script type="text/javascript" src="http://XXX自己服务器下的地址XXXX/web-apps/apps/api/documents/api.js"></script>
            </style>
    
    还有根据不同的格式属性值不同
        "document": {
          "fileType": "docx",
          .......
        },
        "documentType": "text",
    
    

    这是官网的属性值

    企业微信截图_16709866076042.png

    相关文章

      网友评论

          本文标题:onlyoffice pc在线预览word各种文件

          本文链接:https://www.haomeiwen.com/subject/oqnkqdtx.html