用 pageoffice 实现文档的在线编辑以及文档流转
1: 流程
用修改无痕迹模式起草文件,各个领导批注自己意见的时候使用强制留痕模式打开,文员清稿的时候用核稿模式打开,还有最后只读模式打开发布的正式文件。其中在领导批注环节也演示了PageOffice提供的手写功能,在文件核稿之后可以加盖印章。
2:详细代码
poserver
com.zhuozhengsoft.pageoffice.poserver.Server
poserver
/poserver.zz
poserver
/sealsetup.exe
poserver
/posetup.exe
poserver
/pageoffice.js
poserver
/jquery.min.js
poserver
/pobstyle.css
adminseal
com.zhuozhengsoft.pageoffice.poserver.AdminSeal
adminseal
/adminseal.zz
adminseal
/loginseal.zz
adminseal
/sealimage.zz
mht
message/rfc822
adminseal-password
111111
在线编辑 →
张三批阅 →
李四批阅 →
文员清稿 →
import="java.util.*,com.zhuozhengsoft.pageoffice.*,com.zhuozhengsoft.pageoffice.wordwriter.*"
pageEncoding="UTF-8"%>
String type = (String) request.getParameter("type");
String user = (String) request.getParameter("user");
PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
//设置服务器页面
poCtrl.setServerPage(request.getContextPath() + "/poserver.zz");
//添加自定义按钮
poCtrl.addCustomToolButton("保存", "Save", 1);
poCtrl.addCustomToolButton("全屏/还原", "IsFullScreen", 4);
//设置保存页面
poCtrl.setSaveFilePage("SaveFile.jsp");
if ("creat".equals(type)) {
//普通编辑模式打开文档 打开Word文档
poCtrl.webOpen("doc/test.doc", OpenModeType.docNormalEdit,
"张佚名");
}
if ("check".equals(type)) {
poCtrl.addCustomToolButton("显示/隐藏痕迹", "Show_HidRevisions", 5);
poCtrl.addCustomToolButton("领导圈阅", "StartHandDraw", 3);
poCtrl.addCustomToolButton("插入键盘批注", "StartRemark", 3);
poCtrl.addCustomToolButton("分层显示手写批注", "ShowHandDrawDispBar",7);
//强制留痕模式打开文档 打开Word文档
poCtrl.webOpen("doc/test.doc", OpenModeType.docRevisionOnly,user);
}
if ("accept".equals(type)) {
poCtrl.addCustomToolButton("显示/隐藏痕迹", "Show_HidRevisions", 5);
poCtrl.addCustomToolButton("插入印章/签名", "InsertSeal", 2);
poCtrl.addCustomToolButton("接受所有修订", "AcceptAllRevisions", 5);
poCtrl .addCustomToolButton("分层显示手写批注", "ShowHandDrawDispBar",7);
//核稿模式打开文档 打开Word文档
poCtrl.webOpen("doc/test.doc", OpenModeType.docAdmin, "张佚名");
}
if ("publish".equals(type)) {
poCtrl.addCustomToolButton("另存到本地", "ShowDialog(0)", 5);
poCtrl.addCustomToolButton("页面设置", "ShowDialog(1)", 0);
poCtrl.addCustomToolButton("打印", "ShowDialog(2)", 6);
poCtrl.setMenubar(false);
poCtrl.setOfficeToolbars(false);
//只读模式打开文档 打开Word文档
poCtrl.webOpen("doc/test.doc", OpenModeType.docReadOnly, "张佚名");
}
%>
//保存
function Save() {
document.getElementById("PageOfficeCtrl1").WebSave();
}
//全屏/还原
function IsFullScreen() {
document.getElementById("PageOfficeCtrl1").FullScreen = !document.getElementById("PageOfficeCtrl1").FullScreen;
}
//显示/隐藏痕迹
function Show_HidRevisions() {
document.getElementById("PageOfficeCtrl1").ShowRevisions = !document.getElementById("PageOfficeCtrl1").ShowRevisions;
}
//领导圈阅签字
function StartHandDraw() {
document.getElementById("PageOfficeCtrl1").HandDraw.SetPenWidth(5);
document.getElementById("PageOfficeCtrl1").HandDraw.Start();
}
// 插入键盘批注
function StartRemark() {
var appObj = document.getElementById("PageOfficeCtrl1").WordInsertComment();
}
//分层显示手写批注
function ShowHandDrawDispBar() {
document.getElementById("PageOfficeCtrl1").HandDraw.ShowLayerBar(); ;
}
//接受所有修订
function AcceptAllRevisions() {
document.getElementById("PageOfficeCtrl1").AcceptAllRevisions();
}
function ShowDialog(index) {
if (index == 0) document.getElementById("PageOfficeCtrl1").ShowDialog(2);
if (index == 1) document.getElementById("PageOfficeCtrl1").ShowDialog(5);
if (index == 2) document.getElementById("PageOfficeCtrl1").ShowDialog(4);
}
//插入印章
function InsertSeal(){
try {
document.getElementById("PageOfficeCtrl1").ZoomSeal.AddSeal();
} catch(e) {}
}
保存代码
FileSaver fs=new FileSaver(request,response);
fs.saveToFile(request.getSession().getServletContext().getRealPath("doc/")+"/"+fs.getFileName());
fs.close();
3:注意事项
(1)此示例演示了简单的文件流转,没有返回. 如需返回重新编辑审阅文档,可以写自己的逻辑
(2)本示例 用到的印章是pgaeoffice 自带的简易印章. 用的是 sqlite 数据库. 必须复制sqlite 的jar 以及 poseal.db文件. 可以到http://www.zhuozhengsoft.com/dowm/ 下载试用程序.里面有对应的文件