在咱們的項目中有時候會遇到在線打開PPT文檔的需求,這個需求看似很簡單,只是將每一頁的內容放在網頁上瀏覽一下。但是實現起來又無從下手。其實它是必定會用到微軟的接口的,要否則怎麼讓程序識別渲染PPT文件呢?javascript
今天小編就把以前用過的很簡單就能知足需求的一個技術介紹一下——pageoffice。而且文章後面免費提供註冊碼!!!html
去剛纔下載的集成文件中找到lib,將裏面的內容放在項目web-inf的lib中引入jar包,而後將web.xml的pageoffice配置引入到本身項目的wb.xml中java
寫button以前先引入pageoffice須要的js文件jquery
<script type="text/javascript" src="/jquery.min.js"></script>
web
<script type="text/javascript" src="/pageoffice.js" id="po_js_main"></script>
瀏覽器
而後添加a標籤服務器
<a href="javascript:POBrowser.openWindowModeless('openPPT.jsp', 'width=1050px;height=900px;');">打開PPT文檔</a>
<%@ page language="java"
app
import="java.util.*,com.zhuozhengsoft.pageoffice.*"
less
pageEncoding="utf-8"%>
webapp
<%
PageOfficeCtrl poCtrl=new PageOfficeCtrl(request);
//設置服務器頁面
poCtrl.setServerPage(request.getContextPath()+"/poserver.zz");
//添加自定義按鈕
poCtrl.addCustomToolButton("保存","Save",1);
poCtrl.addCustomToolButton("關閉","Close",21);
//設置保存頁面
poCtrl.setSaveFilePage("SaveFile.jsp");
//打開Word文檔
String fileName = "test.ppt";
poCtrl.webOpen(fileName,OpenModeType.pptNormalEdit,"張佚名");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style>
#main{
width:1040px;
height:890px;
border:#83b3d9 2px solid;
background:#f2f7fb;
}
#shut{
width:45px;
height:30px;
float:right;
margin-right:-1px;
}
#shut:hover{
}
</style>
</head>
<body style="overflow:hidden" >
<script type="text/javascript">
function Save() {
document.getElementById("PageOfficeCtrl1").WebSave();
}
function Close() {
window.external.close();
}
</script>
<div id="main">
<div id="shut"><img src="../js/close.png" onclick="Close()" title="關閉" /></div>
<div id="content" style="height:850px;width:1036px;overflow:hidden;">
<%=poCtrl.getHtmlCode("PageOfficeCtrl1")%>
</div>
</div>
</body>
</html>
<%@ page language="java" import="java.util.*,com.zhuozhengsoft.pageoffice.*" pageEncoding="utf-8"%>
<%
FileSaver fs=new FileSaver(request,response);
fs.saveToFile(request.getSession().getServletContext().getRealPath("/")+fs.getFileName());
fs.close();
%>
--------------------- 本文來自 it_zhang81 的CSDN 博客 ,全文地址請點擊:https://blog.csdn.net/IT_zhang81/article/details/82906949?utm_source=copy