public class WpsWatermarkProcessor extends AbstractWatermarkProcessor {
@Override
public void process(WatermarkParam watermarkParam) throws WatermarkException {
super.process(watermarkParam);
}
@Override
public Boolean supportType(File file) {
return super.supportType(file);
}
}
WatermarkUtils.addProcessor(new WpsWatermarkProcessor());
静态调用WatermarkUtils.addWatermark()即可;
File file = new File("F:\\图片_3 - 副本.jpg");
// File imageFile = new File("F:\\1 - 副本.jpeg");
SrcFile srcFile = SrcFile.builder().file(file).build();
ImageFile imageFile = ImageFile.builder().text("小i机器人").build();
WatermarkParam param = WatermarkParam.builder()
.file(srcFile)
.imageFile(imageFile)`
.degree(30F)
// .imageFile(imageFile)
// .xMove(100)
// .yMove(100)
.alpha(1F)
.bespread(Boolean.TRUE)
.color(Color.red)
.build();
WatermarkUtils.addWatermark(param);
以文件模式实现 doc, docx, xlsx, xls, ppt, pptx, image, pdf 增加水印
增加文件字节传参形式,减少实体文件的存在