用pageOffice控件实现 office word文档 编辑Word加水印的功能

OA办公中,业务需要多人编辑word文档,需要加文字水印的功能。

怎么实现word文档的编辑加文字水印呢?

1 实现方法

通过pageOffice实现简单的在线打开编辑word时,
通过设置doc.getWaterMark().setText(“PageOffice开发平台”); 属性,给Word文档添加文字水印。
就可以实现编辑word中增加水印的功能

2 实现过程

以java的springboot框架为例

1 集成pageOffice

https://www.zhuozhengsoft.com/dowm/
在这里插入图片描述
从pageOffice官网
下载页面,找到springboot的集成示例,按照里面的集成明说,可以集成到自己的springboot项目中。

2 在线打开编辑word

在这里插入图片描述
可以按照这个示例首先实现最基本的打开word的方法。

3 通过代码实现编辑word中增加水印的功能

代码参考以下功能示例代码
在这里插入图片描述
control代码

点击查看代码

@RestController
@RequestMapping(value = "/AddWaterMark")
public class AddWaterMarkController {
    @RequestMapping(value = "/Word", method = RequestMethod.GET)
    public ModelAndView showWord(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        poCtrl.setServerPage(request.getContextPath() + "/poserver.zz");//设置服务页面

        WordDocument doc = new WordDocument();
        //添加水印 ,设置水印的内容
        doc.getWaterMark().setText("PageOffice开发平台");
        poCtrl.setWriter(doc);
        //打开Word文档
        poCtrl.webOpen("/doc/AddWaterMark/test.doc", OpenModeType.docNormalEdit, "张三");
        request.setAttribute("pageoffice", poCtrl.getHtmlCode("PageOfficeCtrl1"));
        ModelAndView mv = new ModelAndView("AddWaterMark/Word");
        return mv;
    }


}

 


html代码

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>添加水印</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
</head>
<body>
<!--**************   卓正 PageOffice组件 ************************-->
<div style=" width:auto; height:700px;" th:utext="${pageoffice}">
</div>
</body>
</html>


通过以上代码,可以实现编辑word中增加水印的功能

4 效果图

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值