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

master
zengwh 6 years ago
parent 84926bb86d
commit db4832ae6e

@ -250,8 +250,7 @@ public class FontShowRecordController {
* @param flag
*/
@RequestMapping(value = "showRecordContentBloodFont")
@ResponseBody
public ResultUtil showRecordContentBloodFont(String patientId, String scanPages, String sources, String flag) throws Exception{
public String showRecordContentBloodFont(String patientId, String scanPages, String sources, String flag,Model model) throws Exception{
String pdfTempRoot = "pdfTemp";
//临时保存pdf的文件目录
String fileOutRoot = WATERPICPATH + pdfTempRoot;
@ -266,6 +265,7 @@ public class FontShowRecordController {
//组织前台访问临时pdf路径
String httpFilePath = EMRRECORDJSP + "\\reload\\" + filePath;
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" %>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>预览PDF</title>
<meta http-equiv=X-UA-Compatible IE=EmulateIE7>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<!--[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">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<META http-equiv="Content-Style-Type" content="text/css">
<META http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript" src="${path}/static/js/jquery-1.11.3.min.js"></script>
<TITLE>pdf预览iframe框</TITLE>
<script>
var path = "${path}";
</script>
<style type="text/css">
html,body{
width:100%;
height:100%;
margin:0;
padding:0;
background-color: #F2F2F2;
}
</style>
</head>
<body onkeydown="disabledPrint()">
<input hidden type="hidden" id="httpFilePath" value="${httpFilePath}">
<script type="text/javascript" src="${path}/static/js/font/showRecordIframeBloodCommom.js"></script>
<script>
location.href = $("#httpFilePath").val();
//屏蔽鼠标右键
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>
</HEAD>
<body id="noprint" oncontextmenu="return false" onselectstart="return false" ondragstart="return false" onbeforecopy="return false" oncopy=document.selection.empty() onselect=document.selection.empty()>
<div>
<p style="margin-top:-50px;margin-bottom:0px;" media="print" class="noprint">
<object classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" id="Pdf1" width="100%" height="120%" oncontextmenu="return false" oncontextmenu="window.event.returnvalue=false" media="print">
<param name="_Version" value="327680">
<param name="_ExtentX" value="3000">
<param name="_ExtentY" value="16323">
<param name="_StockProps" value="0">
<param name="SRC" value="${httpFilePath}">
</object>
</p>
</div>
<script type="text/javascript" src="${path}/static/js/font/showRecordIframeBloodCommom.js"></script>
</body>
</HTML>

@ -105,8 +105,7 @@ aria-labelledby="myModalLabel" aria-hidden="true">
</div>
</div>
<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>
<script type="text/javascript" src="${path}/static/js/font/showRecordIframeBloodFont.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
var isIE = function(ver) {
var b = document.createElement('b')
@ -25,12 +7,15 @@ var isIE = function(ver) {
//初始化函数
$(function(){
$('.contentDiv').css('height', '100%').css('height', '-=140px');
//加载iframe
//谷歌
$("#iframe").prop("src",path+"/commom/showRecordIframeBlood?patientId="+$("#patientId").val()+"&flag=file_path"+"&rootPaths="+$("#rootPaths").val());
/*var ie = isIE(8);
if(ie) {
//加载iframe
//ie8加载iframe
$("#iframe").prop("src",path+"/font/showRecordIframeBloodFont?patientId="+$("#patientId").val()+"&flag=file_path");
}else{
//谷歌
$("#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 () {
var pdfresult = isAcrobatPluginInstall();
if(!pdfresult){
alert("对不起,您还没有安装PDF阅读器软件呢,为了方便预览PDF文档,请选择安装");
location = path + "/static/js/font/AdbeRdr70_chs_full.exe";
var checkAdobeReader = Check_AdobeReader();
if(checkAdobeReader != 'Acrobat Version: 6.0'){
alert("对不起,您还没有安装PDF阅读器软件呢,为了方便预览PDF文档,请选择安装!");
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 = [
@ -69,7 +68,58 @@ var tree = $('#data').data('jstree', false).empty().jstree({
"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选中、取消选中逻辑
function selectAssortIds(){
var instance = $('#data').jstree(true);//获取jstree对象
@ -106,53 +156,7 @@ function onloadPdf(){
var sources = $("#sources").val();
var flag = $("#flag").val();
var url = path+"/font/showRecordContentBloodFont?flag="+flag+"&patientId="+patientId+"&scanPages="+assortIds+"&sources="+sources;
$.ajax({
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);
}
$("#iframe1").prop("src",url);
}
//记录打印记录
@ -166,36 +170,3 @@ function printInfoBlood(){
var flag = $("#flag").val();
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