I have written a code to add a watermark to an existing .doc file.
Here is the code I’ve tried so far:
public static void main(String[] args)
{
try
{
XWPFDocument xDoc = new XWPFDocument(new FileInputStream("test.doc"));
XWPFHeaderFooterPolicy xFooter = new XWPFHeaderFooterPolicy(xDoc);
xFooter.createWatermark("My Watermark");
}
catch(Exception e) {
e.printStackTrace();
}
}
Getting below error:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.poi.util.IOUtils.copy(Ljava/io/InputStream;Ljava/io/OutputStream;)V
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:50)
at org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:71)
at com.avi.Test.ReadDoc.main(Watermark.java:38)
org.apache.poi.util.IOUtilswill tell you which jar contains it, and at which version acopy(InputStream, OutputStream)method was introduced.