java 流转文件_java 实现 word 文档的在线编辑以及流转

这篇博客展示了如何利用PageOffice控件在Java中实现Word文档的在线编辑和流转功能。通过不同模式(起草、批注、清稿、发布)实现文件处理,并提供了详细代码示例,包括自定义按钮、手写功能以及印章插入等操作。
摘要由CSDN通过智能技术生成

用 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/  下载试用程序.里面有对应的文件

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值