我正在使用 poi-3.9,在 .doc 中设置水印
这是我的代码:
public void setWarterMark()
{
String filesname = "Example1.doc";
try
{
XWPFDocument xDoc = new XWPFDocument(new FileInputStream(filesname));
XWPFHeaderFooterPolicy xFooter = new XWPFHeaderFooterPolicy(xDoc);
xFooter.createWatermark("My Watermark");
System.out.println("Done");
}
catch(Exception e) {
e.printStackTrace();
}
}
控制台显示:
org.apache.poi.POIXMLException: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13]
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:41)
at org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:120)
at com.avi.Test.ReadDoc.main(ReadDoc.java:46)