easy-watermark

πŸ’§ EasyWatermark

🌍 δΈ­ζ–‡ζ–‡ζ‘£
πŸ“· Image Watermark Example | πŸ“„ Pdf Watermark Example | πŸ“ Docx Watermark Example

EasyWatermark is a simple and easy-to-use watermarking framework. It abstracts methods for adding watermarks to various file types. With just a few lines of code, you can add the same style of watermark to different types of files.

πŸš€ Quick Start

1️⃣ Add Dependency

<dependency>
    <groupId>org.easywatermark</groupId>
    <artifactId>easy-watermark</artifactId>
    <version>latest version</version>
</dependency>

2️⃣ Add Watermark

public class WatermarkExample {

    public static void main(String[] args) {
        byte[] result = EasyWatermark.create()
                .file(fileData)
                .text("Easy-Watermark")
                .execute();
    }
    
}

πŸ”§ More Configurations

🎯 Preset Watermark Types

βš™οΈ Watermark Configuration

Use the WatermarkConfig class to set properties like opacity, color, font, and more.

public class WatermarkConfig {
    private float alpha = 1.0f;  // Opacity
    private Color color = Color.BLACK;
    private File fontFile;
    private String fontName = "Dialog";  // Default font
    private int fontSize = 12;
    private int fontStyle = Font.PLAIN;
}

πŸ› οΈ Advanced Usage

Using Preset Watermark Types

public class UsingPresetWatermarkType {

    public static void main(String[] args) {
        byte[] result = EasyWatermark.create()
                .file(fileData)
                .text("Easy-Watermark")
                .easyWatermarkType(EasyWatermarkTypeEnum.CENTER)
                .execute();
    }
  
}

Custom Watermark and Font Configuration

public class CustomWatermarkExample {

    public static void main(String[] args) {
        WatermarkConfig watermarkConfig = new WatermarkConfig();
        watermarkConfig.setAlpha(0.5f);  // Set transparency

        FontConfig fontConfig = new FontConfig();
        fontConfig.setFontSize(30);  // Set font size

        byte[] result = EasyWatermark.create()
                .file(fileData)
                .config(watermarkConfig)
                .config(fontConfig)
                .easyWatermarkType(EasyWatermarkTypeEnum.CENTER)
                .text("Easy-Watermark")
                .execute();
    }
    
}

πŸ“… Development Plan

πŸ™Œ Others

If you have more suggestions, feel free to raise an issue! 😊