OfdShow.jsp 7.23 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.ofd.ocx.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="objectdiv" style="float:left;width:100%;height:100%;"></div>
</body>
<script type="text/javascript">
    var downloadPath = "";
    var uploadPath = "";
    var obj;
    var viewValue;
    var xmlparam="";

    //初始化
    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%";
        obj = OFD.OCX.init("objectdiv", width, height);
        obj.ready(obj._id);
        if (!("ActiveXObject" in window)) {
            obj.jsCallbackFun_InitSetting();
            obj.jsCallbackFun_UpdateInfo();
        }
        fx_openFile(downloadPath);
    }

    //插件调用方法
    function initSetting() {
        obj.setZoomMode('2');
        obj.setDisPlayMode('1');
        obj.setViewPreference('Navigate', '2'); //设置导航
        //fx_setLogURL();
        obj.addTrackInfo(xmlparam);
        obj.setPrintInfo(1);
        obj.setCompositeVisible("sign", true);
        obj.setCompositeVisible("verify", true);
    }


    //回调事件:包括翻页、打印、打印设置
    function UpdateInfo(strkey,strValue){
        if(strkey=="GetCurPageIndex"){
            var curPageIndex=obj.getCurPageIndex();
        }
        else if(strkey == "Print"){
            var log=obj.getLogFileContent();
        }
    }

    //保存
    var saveFile = function(){
        //签章计数
        var newSignCount= obj.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_openFile(filepath) {
        var res = obj.openFile(filepath,false);
    }

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

    //关闭文档
    function fx_closeFile(){
        obj.closeFile(false);
        //ocxFoxit.setCompositeVisible("sign",false);
    }

    //获取版本号
    function fx_getAppVersion(){
        var version = obj.getPluginVersion();
        alert("当前版本号为:"+version);
    }
    //打印设置
    function fx_printSetting() {
        obj.printSetting();
    }
    //打印文件
    function fx_printInfo(title,color){
        obj.printFile(title,color);
    }
    //静默打印
    function fx_quietPrintFile(title, color, isquite) {
        //for(var i=0;i<3;i++){obj.quietPrintFile(title, color, isquite);}
        obj.quietPrintFile(title, color, isquite);
    }
    //获取打印日志信息
    function fx_getLogFileContent() {
        var content= obj.getLogFileContent();
        alert("打印日志内容:"+content);
    }

</script>
<script type="text/javascript" for="ht_foxit" event="OnOpenFile(res)">
    if(res==0){
        //alert("文件打开成功");
    }
</script>

<script type="text/javascript" for="ht_foxit" event="OnSaveFile(res)">
    //alert("上传回调:"+res);
</script>

<script type="text/javascript" for="ht_foxit" event="OnPrintStatus(error)" >
    alert(error);
</script>

<script type="text/javascript" for="ht_foxit" event="OnSignFile(res)">
    alert("所盖的章的证书信息:"+res);
</script>
</html>