java 文档比较功能_[原创]java在线比较两个word文件

一、项目背景

开发文档管理系统或OA办公系统的时候,实现在线处理word文档的功能比较容易,但是也经常会有客户提出文档版本管理的需求,这就需要同时在线打开两个word文件,对比两个不同版本的word文档内容,在网上几乎找不到解决方案。

二、解决方案

集成PageOffice实现在线处理word文件,调用PageOffice的两个word文档对比的功能即可解决此问题,并且调用方法非常简单:

Java后台代码:

PageOfficeCtrl poCtrl1 = newPageOfficeCtrl(request);

poCtrl1.setServerPage(request.getContextPath()+"/poserver.zz");//Create custom toolbar

poCtrl1.addCustomToolButton("保存", "SaveDocument()", 1);

poCtrl1.addCustomToolButton("显示A文档", "ShowFile1View()", 0);

poCtrl1.addCustomToolButton("显示B文档", "ShowFile2View()", 0);

poCtrl1.addCustomToolButton("显示比较结果", "ShowCompareView()", 0);

poCtrl1.setSaveFilePage("/SaveFile");

poCtrl1.wordCompare("doc/A.doc", "doc/B.doc", OpenModeType.docAdmin, "用户名");//关键代码,同时打开两个word文档来对比

Html页面js:

functionSaveDocument() {

document.getElementById("PageOfficeCtrl1").WebSave();

}functionShowFile1View() {

document.getElementById("PageOfficeCtrl1").Document.ActiveWindow.View.ShowRevisionsAndComments = false;

document.getElementById("PageOfficeCtrl1").Document.ActiveWindow.View.RevisionsView = 1;

}functionShowFile2View() {

document.getElementById("PageOfficeCtrl1").Document.ActiveWindow.View.ShowRevisionsAndComments = false;

document.getElementById("PageOfficeCtrl1").Document.ActiveWindow.View.RevisionsView = 0;

}functionShowCompareView() {

document.getElementById("PageOfficeCtrl1").Document.ActiveWindow.View.ShowRevisionsAndComments = true;

document.getElementById("PageOfficeCtrl1").Document.ActiveWindow.View.RevisionsView = 0;

}functionSetFullScreen() {

document.getElementById("PageOfficeCtrl1").FullScreen = !document.getElementById("PageOfficeCtrl1").FullScreen;

}

Html代码中显示PageOffice的代码:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值