OfdShow.jsp
7.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<%@ 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>