spire .doc for java 取消红色警告水印
问题
在使用Spire.Doc的word文档产生了警告水印
(Evaluation Warning: The document was created with Spire.Doc for JAVA.)
引入 poi依赖
<!-- Apache POI -->
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.0</version>
</dependency>
使用poi删除第一行即可
public static void restWord() {
try (FileInputStream fis = new FileInputStream("E:/ygq/开发/test/test.docx");
XWPFDocument document = new XWPFDocument(fis);
FileOutputStream fos = new FileOutputStream("E:/ygq/开发/test/test1.docx")) {
document.removeBodyElement(0);
// 保存修改后的文档
document.write(fos);
} catch (IOException e) {
e.printStackTrace();
}
}