OfdShow4Linux.jsp 6.11 KB
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="java.net.*,weaver.general.Util" %>
<%@ include file="/systeminfo/init_wev8.jsp" %>
<%@ page import="weaver.general.BaseBean" %>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page"/>
<%
    int docid = Util.getIntValue(request.getParameter("docid"), 0);
    int imagefileId = Util.getIntValue(request.getParameter("imagefileId"), 0);
    String isrequest=Util.null2String(request.getParameter("isrequest"));
    int requestid=Util.getIntValue(request.getParameter("requestid"),0);
    String isEdit=request.getParameter("isEdit") ;
    new BaseBean().writeLog("isEdit=======================================" + isEdit);
    //从Cookie中获取sessionKey
    Map<String, Cookie> cookieMap = new HashMap<String, Cookie>();
    Cookie[] cookies = request.getCookies();
    String sessionKey = "jsessionid";
    RecordSet.writeLog("session.getId()====111======================================" + session.getId());
    RecordSet.writeLog("session.getId()====222======================================" + session.getId());
    if (null != cookies) {
        for (Cookie cookie : cookies) {
            RecordSet.writeLog("cookie.getName()====111======================================" + cookie.getName());
            RecordSet.writeLog("cookie.getName()====222======================================" + response.encodeURL(cookie.getName()));
            RecordSet.writeLog("cookie.getValue()====111======================================" + cookie.getValue());
            if(cookie.getValue().equals(session.getId())){
                if(cookie.getName().equalsIgnoreCase("jsessionid")){
                    sessionKey = "jsessionid";
                    break;
                }
                sessionKey = cookie.getName();
            }
        }
    }
    RecordSet.writeLog("sessionKey====111======================================" + sessionKey);
    String hostStr = request.getServerName() + ":" + request.getServerPort();
    String path = "/weaver/weaver.file.FileDownload;" + sessionKey + "=" + request.getRequestedSessionId() + "?docId=" + docid + "&imageFileId=" + imagefileId + "&type=ofd";
    String uploadPath = "/docs/ofd4fuxin/OfdUpload.jsp;" + sessionKey + "=" + request.getRequestedSessionId() + "?docId="+docid+"&imageFileId="+imagefileId+"&isrequest="+isrequest+"&requestid="+requestid;
    RecordSet.writeLog("path====111======================================" + path);
    RecordSet.writeLog("uploadPath====111======================================" + uploadPath);

%>
<html>
<head>
    <script type="text/javascript" src="/js/odoc/Foxit_npapi_new.js"></script>
    <script type="text/javascript" src="/cloudstore/resource/pc/jquery/jquery-1.8.3.min.js"></script>
</head>
<body onload="" onbeforeunload="fx_closeFile()">
<div id="FireFoxOFDDIV" tabindex='1' style="float:left;width:100%;height:100%;"></div>

</body>
<script type="text/javascript">
    var downloadPath = "";
    var uploadPath = "";
    var ocx;

    //初始化
    jQuery(document).ready(function(){
        if(isHttpsRequest()){
            downloadPath = "https://" + "<%=hostStr%>" + "<%=path%>";
            uploadPath = "https://" + "<%=hostStr%>" + "<%=uploadPath%>";
        }else{
            downloadPath = "http://" + "<%=hostStr%>" + "<%=path%>";
            uploadPath = "http://" + "<%=hostStr%>" + "<%=uploadPath%>";
        }
        fx_init();
    });

    function isHttpsRequest(){
        if(window.location.href.indexOf('https://') === 0){
            return true;
        }else{
            return false;
        }
    }

    window.onresize=function(){
        var obj=document.getElementsByTagName("object");
        if(!obj){
            var obj=document.getElementsByTagName("embed");
        }
        obj[0].width="100%";
        obj[0].height="100%";
    }

    //初始化插件
    function fx_init() {

        var width = "100%";
        var height = "100%";

        ocx = foxit.ofdReaderInit("FireFoxOFDDIV", width, height);
        ocx.jsCallbackFun_InitSetting(); // = initSetting;
        ocx.jsCallbackFun_UpdateInfo();
        fx_openFile(downloadPath);
    }

    function initSetting() {
        ocx.setZoomMode('2');
        ocx.setDisPlayMode('1');
        ocx.setViewPreference('Navigate', '2'); //设置导航
        //ocx.addTrackInfo(xmlparam); 设置二维码
        //ocx.setPrintInfo(1);
        ocx.setCompositeVisible("sign", true);
        ocx.setCompositeVisible("verify", true);
    }
    function UpdateInfo(strkey){
        if(strkey=="GetCurPageIndex"){
            var curPageIndex=ocx.getCurPageIndex();
            //document.getElementById("curIndex").value=curPageIndex;
        }
        else if(strkey == "getLogFileContent"){
            fx_getLogFileContent();
        }
    }

    //打开文件
    function fx_openFile(filepath) {
        //fx_setViewPreference();
        var endvalue = ocx.openFile(filepath, false);
        return endvalue;
    }


    //保存
    var saveFile = function(){
        //签章计数
        var newSignCount= ocx.countSignatures();
        if(newSignCount > 0 ){
            jQuery.ajax({
                url:'/odoc/docs/odocCommonAjax.jsp',
                data:{action:'saveGinatureCount',
                    requestid:'<%=requestid%>',
                    docid:'<%=docid%>',
                    singCount:newSignCount,
                },
                type:'POST',
                dataType:'json',
                success:function(){
                }
            });
        }
        var saveResult = fx_saveFile(uploadPath);
        if(saveResult){
            alert("<%=SystemEnv.getHtmlLabelName(501784, user.getLanguage())%>");
        }else{
            alert("<%=SystemEnv.getHtmlLabelName(501785, user.getLanguage())%>");
        }

    }

    //保存为指定的文件
    function fx_saveFile(path) {
        var res = ocx.saveFile(path);
        return res;
    }

    //关闭文档
    function fx_closeFile(){
        ocx.closeFile(false);
    }

    //获取打印日志信息
    function fx_getLogFileContent() {
        var content= obj.getLogFileContent();
        alert("打印日志内容:"+content);
    }

</script>

</html>