onlypdfview.jsp 3.12 KB

<%@ page language="java" contentType="text/html; charset=UTF-8"%>


<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
<%@ page import="weaver.docs.pdf.docpreview.ConvertPDFTools"%>
<%@ page import="weaver.general.*"%>
<%@ include file="/systeminfo/init_wev8.jsp" %>
<link rel="stylesheet" href="/css/init_wev8.css" type="text/css" />
<%
	int imageFileId = -1;
	String aboutdoc = Util.null2String(request.getParameter("aboutdoc"),"-1");
	String sql = "select count(aboutdoc) from CE_NonstandardFunction where aboutdoc = " + aboutdoc;
	RecordSet.executeSql(sql);
	boolean flag = false;
	boolean isPDF = false;
	boolean canView = false;
	if(RecordSet.next()){
	    flag = true;
	}
	String canDownload="false";
	String canPrint="false";
	String imagefilename = "";
	if(true)
	{
	    sql = "select imagefilename,imagefileid from DocImageFile where docid = " + aboutdoc;
		RecordSet.executeSql(sql);
	    if(RecordSet.next()){
	        imageFileId = RecordSet.getInt("imagefileid");
	        isPDF = Util.null2String(RecordSet.getString("imagefilename"),"").endsWith(".pdf");
	        imagefilename = Util.null2String(RecordSet.getString("imagefilename"),"document.pdf");
	        if(imagefilename.endsWith(".ppt") || 
	                imagefilename.endsWith(".pptx") || 
	                imagefilename.endsWith(".doc") || 
	                imagefilename.endsWith(".docx") || 
	                imagefilename.endsWith(".xls") || 
	                imagefilename.endsWith(".xlsx") || 
	                imagefilename.endsWith(".wps"))
	        {
	            canView = true;
	        }
		}
	try{
	    if(canView)
	    {
		int htmlFileId = 0;
		if("true".equals(isPDF))
		{
			htmlFileId = imageFileId;
		}
		else
		{
			sql = "select * from pdf_imagefile where imagefileid="+imageFileId;
			RecordSet.executeSql(sql);
			if(RecordSet.next()){
				htmlFileId = Util.getIntValue(RecordSet.getString("pdfimagefileid"),0);
			}
			else
			{
				ConvertPDFTools convertPDFTools = new ConvertPDFTools();
				htmlFileId= convertPDFTools.conertToPdf(imageFileId+"");
			}
		}
		if(htmlFileId>0){
		%>
		<script type="text/javascript">
				try{
					document.body.style.overflow="hidden";
				}catch(e){}
				
				function hideLoading(){
					try{
						parent.finalDo("view");
					}catch(e){
						window.setTimeout(function(){
								try{
									parent.finalDo("view");
								}catch(e){}
									},1000);					
					}
				}
		</script>
<iframe id="htmlShowContent" frameborder="0"
	style="width: 100%; height: 100%;"
	src="<%="/docs/pdfview/web/pdfViewer.jsp?imagefilename="+imagefilename+"&canPrint=false&canDownload=false&aboutdoc="+aboutdoc+"&pdfimagefileid="+htmlFileId %>"
	onload="hideLoading();"></iframe>
	<% } } else {
		response.sendRedirect("/weaver/weaver.homepage.HomepageCreateImage?aboutdoc="+aboutdoc+"&fileid=" + imageFileId) ;
	}
	}catch(Exception e){
		RecordSet.writeLog(e);
		request.setAttribute("labelid","123456");
		request.getRequestDispatcher("/wui/common/page/sysRemind.jsp").forward(request,response);
		return;
	}
	}
	else
	{ %>
	<%--500659 您查看的不是非标文档--%>
<%=SystemEnv.getHtmlLabelName(500659, user.getLanguage())%>

<%
	}
%>