Giter Club home page Giter Club logo

watermark's Introduction

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

增加文件字节传参形式,减少实体文件的存在

watermark's People

Contributors

a852203465 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.