ie8浏览器预览pdf接口隐藏adobe插件保存和打印工具栏

master
zengwh 6 years ago
parent 84926bb86d
commit db4832ae6e

@ -250,8 +250,7 @@ public class FontShowRecordController {
* @param flag * @param flag
*/ */
@RequestMapping(value = "showRecordContentBloodFont") @RequestMapping(value = "showRecordContentBloodFont")
@ResponseBody public String showRecordContentBloodFont(String patientId, String scanPages, String sources, String flag,Model model) throws Exception{
public ResultUtil showRecordContentBloodFont(String patientId, String scanPages, String sources, String flag) throws Exception{
String pdfTempRoot = "pdfTemp"; String pdfTempRoot = "pdfTemp";
//临时保存pdf的文件目录 //临时保存pdf的文件目录
String fileOutRoot = WATERPICPATH + pdfTempRoot; String fileOutRoot = WATERPICPATH + pdfTempRoot;
@ -266,6 +265,7 @@ public class FontShowRecordController {
//组织前台访问临时pdf路径 //组织前台访问临时pdf路径
String httpFilePath = EMRRECORDJSP + "\\reload\\" + filePath; String httpFilePath = EMRRECORDJSP + "\\reload\\" + filePath;
commomService.showRecordContentBloodFont(patientId,scanPages,sources,flag,fileOutPath); commomService.showRecordContentBloodFont(patientId,scanPages,sources,flag,fileOutPath);
return ResultUtil.ok(httpFilePath); model.addAttribute("httpFilePath",httpFilePath);
return "font/showPdfFrameFont";
} }
} }

@ -2,57 +2,29 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<c:set var="path" value="${pageContext.request.contextPath}"/> <c:set var="path" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <HTML>
<head> <HEAD>
<meta charset="utf-8" /> <META http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>预览PDF</title> <META http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv=X-UA-Compatible IE=EmulateIE7> <META http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <script type="text/javascript" src="${path}/static/js/jquery-1.11.3.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"> <TITLE>pdf预览iframe框</TITLE>
<!--[if lt IE 9]>
<script src="${path}/static/js/jquery-1.11.3.min.js"></script>
<script src="${path}/static/js/html5shiv.js"></script>
<script src="${path}/static/js/respond.min.js"></script>
<![endif]-->
<script src="${path}/static/js/jquery-1.11.3.min.js"></script>
<link rel="shortcut icon" href="${path}/static/js/favicon.ico">
<script> <script>
var path = "${path}"; var path = "${path}";
</script> </script>
<style type="text/css"> </HEAD>
html,body{ <body id="noprint" oncontextmenu="return false" onselectstart="return false" ondragstart="return false" onbeforecopy="return false" oncopy=document.selection.empty() onselect=document.selection.empty()>
width:100%; <div>
height:100%; <p style="margin-top:-50px;margin-bottom:0px;" media="print" class="noprint">
margin:0; <object classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" id="Pdf1" width="100%" height="120%" oncontextmenu="return false" oncontextmenu="window.event.returnvalue=false" media="print">
padding:0; <param name="_Version" value="327680">
background-color: #F2F2F2; <param name="_ExtentX" value="3000">
} <param name="_ExtentY" value="16323">
</style> <param name="_StockProps" value="0">
</head> <param name="SRC" value="${httpFilePath}">
<body onkeydown="disabledPrint()"> </object>
<input hidden type="hidden" id="httpFilePath" value="${httpFilePath}"> </p>
<script type="text/javascript" src="${path}/static/js/font/showRecordIframeBloodCommom.js"></script> </div>
<script> <script type="text/javascript" src="${path}/static/js/font/showRecordIframeBloodCommom.js"></script>
location.href = $("#httpFilePath").val(); </body>
//屏蔽鼠标右键 </HTML>
document.oncontextmenu = function(e) {
var e = e || window.event;
e.returnValue = false;
return false;
}
//禁止快捷键打印
function disabledPrint(){
if(event.keyCode==80 && event.ctrlKey){
event.keyCode=0;
event.returnValue=false;
}
if (event.ctrlKey && event.keyCode == 83) {
event.preventDefault();
event.returnValue = false;
return false;
}
}
$("#buttons").remove();
</script>
</body>
</html>

@ -105,8 +105,7 @@ aria-labelledby="myModalLabel" aria-hidden="true">
</div> </div>
</div> </div>
<div class="content-right"> <div class="content-right">
<iframe type="application/pdf" width="100%" height="100%" src="" id="iframe1" frameborder="0" onkeydown="disabledPrint()"></iframe> <iframe width="100%" height="100%" src="" id="iframe1" frameborder="0" onkeydown="disabledPrint()"></iframe>
</div> </div>
<script type="text/javascript" src="${path}/static/js/font/showRecordIframeBloodFont.js"></script> <script type="text/javascript" src="${path}/static/js/font/showRecordIframeBloodFont.js"></script>
<script type="text/javascript" src="${path}/static/js/font/showRecordIframeBloodCommom.js"></script> <script type="text/javascript" src="${path}/static/js/font/showRecordIframeBloodCommom.js"></script>

@ -1,21 +1,3 @@
//屏蔽鼠标右键
document.oncontextmenu = function(e) {
var e = e || window.event;
e.returnValue = false;
return false;
}
//禁止快捷键打印
function disabledPrint(){
if(event.keyCode==80 && event.ctrlKey){
event.keyCode=0;
event.returnValue=false;
}
if (event.ctrlKey && event.keyCode == 83) {
event.preventDefault();
event.returnValue = false;
return false;
}
}
//判断是否是ie8 //判断是否是ie8
var isIE = function(ver) { var isIE = function(ver) {
var b = document.createElement('b') var b = document.createElement('b')
@ -25,12 +7,15 @@ var isIE = function(ver) {
//初始化函数 //初始化函数
$(function(){ $(function(){
$('.contentDiv').css('height', '100%').css('height', '-=140px'); $('.contentDiv').css('height', '100%').css('height', '-=140px');
//加载iframe
//谷歌
$("#iframe").prop("src",path+"/commom/showRecordIframeBlood?patientId="+$("#patientId").val()+"&flag=file_path"+"&rootPaths="+$("#rootPaths").val()); $("#iframe").prop("src",path+"/commom/showRecordIframeBlood?patientId="+$("#patientId").val()+"&flag=file_path"+"&rootPaths="+$("#rootPaths").val());
/*var ie = isIE(8); /*var ie = isIE(8);
if(ie) { if(ie) {
//加载iframe //ie8加载iframe
$("#iframe").prop("src",path+"/font/showRecordIframeBloodFont?patientId="+$("#patientId").val()+"&flag=file_path"); $("#iframe").prop("src",path+"/font/showRecordIframeBloodFont?patientId="+$("#patientId").val()+"&flag=file_path");
}else{ }else{
//谷歌
$("#iframe").prop("src",path+"/commom/showRecordIframeBlood?patientId="+$("#patientId").val()+"&flag=file_path"+"&rootPaths="+$("#rootPaths").val()); $("#iframe").prop("src",path+"/commom/showRecordIframeBlood?patientId="+$("#patientId").val()+"&flag=file_path"+"&rootPaths="+$("#rootPaths").val());
}*/ }*/
//加载其他诊断名称鼠标滑过显示全部文本 //加载其他诊断名称鼠标滑过显示全部文本

@ -1,12 +1,11 @@
// var obj = new ActiveXObject("AcroPDF.PDF.1"); //下载adobe地址
//http://ardownload.adobe.com/pub/adobe/reader/win/9.x/9.3/chs/AdbeRdr930_zh_CN.exe
window.onload = function () { window.onload = function () {
var pdfresult = isAcrobatPluginInstall(); var checkAdobeReader = Check_AdobeReader();
if(!pdfresult){ if(checkAdobeReader != 'Acrobat Version: 6.0'){
alert("对不起,您还没有安装PDF阅读器软件呢,为了方便预览PDF文档,请选择安装"); alert("对不起,您还没有安装PDF阅读器软件呢,为了方便预览PDF文档,请选择安装!");
location = path + "/static/js/font/AdbeRdr70_chs_full.exe"; location = path + "/static/js/font/AdbeRdr60_chs_full.exe";
} }
// obj.LoadFile("http://192.168.1.3:8083/emr_record/reload/pdfTemp/09.pdf")
} }
//树操作 //树操作
/*var data = [ /*var data = [
@ -69,7 +68,58 @@ var tree = $('#data').data('jstree', false).empty().jstree({
"tie_selection": false "tie_selection": false
}, },
}); });
function Check_AdobeReader() {
var displayString;
var acrobat = new Object();
acrobat.installed = false;
acrobat.version = "0.0";
if (navigator.plugins && navigator.plugins.length) {
for (x = 0; x < navigator.plugins.length; x++) {
if (navigator.plugins[x].description.indexOf("Adobe Acrobat") != -1) {
acrobat.version = parseFloat(navigator.plugins[x].description.split("Version ")[1]);
if (acrobat.version.toString().length == 1) acrobat.version += ".0";
acrobat.installed = true;
displayString = "Acrobat Version: " + acrobat.version;
break;
} else if (navigator.plugins[x].description.indexOf("Adobe PDF Plug-In") != -1) {
acrobat.installed = true;
acrobat.version = "8+";
displayString = "Acrobat Version 8 or Above";
}
}
} else if (window.ActiveXObject) {
for (x = 2; x < 10; x++) {
try {
oAcro = eval("new ActiveXObject('PDF.PdfCtrl." + x + "');");
if (oAcro) {
acrobat.installed = true;
acrobat.version = x + ".0";
displayString = "Acrobat Version: " + acrobat.version;
}
}
catch (e) { }
}
try {
oAcro4 = new ActiveXObject("PDF.PdfCtrl.1");
if (oAcro4) {
acrobat.installed = true;
acrobat.version = '4.0';
displayString = 'Acrobat Version: ' + acrobat.version;
}
}
catch (e) { }
try {
oAcro7 = new ActiveXObject('AcroPDF.PDF.1');
if (oAcro7) {
acrobat.installed = true;
acrobat.version = '7.0';
displayString = 'Acrobat Version: ' + acrobat.version;
}
}
catch (e) { }
}
return displayString;
}
//checkBox选中、取消选中逻辑 //checkBox选中、取消选中逻辑
function selectAssortIds(){ function selectAssortIds(){
var instance = $('#data').jstree(true);//获取jstree对象 var instance = $('#data').jstree(true);//获取jstree对象
@ -106,53 +156,7 @@ function onloadPdf(){
var sources = $("#sources").val(); var sources = $("#sources").val();
var flag = $("#flag").val(); var flag = $("#flag").val();
var url = path+"/font/showRecordContentBloodFont?flag="+flag+"&patientId="+patientId+"&scanPages="+assortIds+"&sources="+sources; var url = path+"/font/showRecordContentBloodFont?flag="+flag+"&patientId="+patientId+"&scanPages="+assortIds+"&sources="+sources;
$.ajax({ $("#iframe1").prop("src",url);
type:'get',
url:url,
success:function(data){
if(data.code == 0){
if(data.msg != ''){
$("#iframe1").prop("src",data.msg);
var html = '<script>';
html += 'for(var i = 0;i<30;i++){fireKeyEvent(document.getElementsByTagName(\'body\'),\'keydown\',33);}';
html += '</script>';
$("#iframe1").append(html);
}
}
}
})
}
function fireKeyEvent(el, evtType, keyCode) {
var evtObj;
if (document.createEvent) {
if (window.KeyEvent) {//firefox 浏览器下模拟事件
evtObj = document.createEvent('KeyEvents');
evtObj.initKeyEvent(evtType, true, true, window, true, false, false, false, keyCode, 0);
} else {//chrome 浏览器下模拟事件
evtObj = document.createEvent('UIEvents');
evtObj.initUIEvent(evtType, true, true, window, 1);
delete evtObj.keyCode;
if (typeof evtObj.keyCode === "undefined") {//为了模拟keycode
Object.defineProperty(evtObj, "keyCode", { value: keyCode });
} else {
evtObj.key = String.fromCharCode(keyCode);
}
if (typeof evtObj.ctrlKey === 'undefined') {//为了模拟ctrl键
Object.defineProperty(evtObj, "ctrlKey", { value: true });
} else {
evtObj.ctrlKey = true;
}
}
el.dispatchEvent(evtObj);
} else if (document.createEventObject) {//IE 浏览器下模拟事件
console.log(2)
evtObj = document.createEventObject();
evtObj.keyCode = keyCode
el.fireEvent('on' + evtType, evtObj);
}
} }
//记录打印记录 //记录打印记录
@ -166,36 +170,3 @@ function printInfoBlood(){
var flag = $("#flag").val(); var flag = $("#flag").val();
post(path+'/template/printInfoBlood',{"patientIds":patientId,"assortIds":assortIds,"typeId":typeId,"flag":flag}); post(path+'/template/printInfoBlood',{"patientIds":patientId,"assortIds":assortIds,"typeId":typeId,"flag":flag});
} }
//判断是否ie8
function isAcrobatPluginInstall() {
var flag = false;
if (window.ActiveXObject) {
for (x = 2; x < 10; x++) {
try {
oAcro = eval("new ActiveXObject('PDF.PdfCtrl." + x + "');");
if (oAcro) {
flag = true;
}
} catch (e) {
flag = false;
}
}
try {
oAcro4 = new ActiveXObject('PDF.PdfCtrl.1');
if (oAcro4)
flag = true;
} catch (e) {
flag = false;
}
try {
oAcro7 = new ActiveXObject('AcroPDF.PDF.1');
if (oAcro7)
flag = true;
} catch (e) {
flag = false;
}
}else{
flag = true;
}
return flag;
}
Loading…
Cancel
Save