java operation word to generate watermark

Application Scenarios

         In order to protect copyright or identify the authenticity of files, sometimes it is necessary to dynamically add watermarks to the generated Word files. The WaterMark class of the PageOffice component encapsulates the function of adding watermarks to online edited Word files, and the calling interface is very simple.

The namespace

         com.zhuozhengsoft.pageoffice.wordwriter to which the WaterMark class belongs

supports two types of watermarks

  Inserting text watermarks (core code):

1 WordDocument doc =new WordDocument();
2 //Add a watermark, the parameter in the setText(String) method is to be added The content of the watermark
3 doc.getWaterMark().setText("PageOffice development platform");
4 poCtrl1.setWriter(doc);//Don't forget this sentence
  Text watermark effect:

  

  insert image watermark (core code):

1 WordDocument doc = new WordDocument();
2 //Add a watermark, the parameter in the setImage(String) method is the url address of the watermark image to be added
3 doc.getWaterMark().setImage("images/logo.png");
4 poCtrl1.setWriter (doc);//Don't forget this sentence
  Picture watermark effect:

  

Source code download

  Visit : http://www.zhuozhengsoft.com/dowm/, download PageOffice for Java, after decompression, copy the Samples4 folder to the Webapps directory of Tomcat, visit: http://localhost:8080/Samples4/index. html, see the example: 2. 9. Add a watermark to the Word document

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325984292&siteId=291194637