Watermark
java实现office办公套件,pdf增加水印
Install / Use
/learn @a852203465/WatermarkREADME
Java 实现 doc, docx, xlsx, xls, ppt, pptx, image, pdf 增加水印
1 自定义格式文档增加水印
1.1 自定义类继承 AbstractWatermarkProcessor 类
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);
}
}
1.2 将自定义类添加到处理集合中
WatermarkUtils.addProcessor(new WpsWatermarkProcessor());
2 使用方式
静态调用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);
3. 版本记录
3.1 v1.0
以文件模式实现 doc, docx, xlsx, xls, ppt, pptx, image, pdf 增加水印
3.2 v1.1
增加文件字节传参形式,减少实体文件的存在
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
