groupdocs-watermark / GroupDocs.Watermark-for-Java

GroupDocs.Watermark for Java examples, plugins and showcase projects
https://products.groupdocs.com/watermark/Java
MIT License
8 stars 3 forks source link

Watermark Images & Documents via Java

GroupDocs.Watermark is a Java library to add text or image watermarks to Office, OpenOffice, PDF & Visio documents as well as all popular image formats. It also allows the developers to search and remove previously added watermarks (including watermarks added by third-party tools).

Directory Description
Examples Java examples and sample documents for you to get started quickly.

Add, Remove or Search for Watermarks

Get Started with GroupDocs.Watermark for Java

GroupDocs.Watermark for Java requires J2SE 7.0 (1.7), J2SE 8.0 (1.8) or above. Please install Java first if you do not have it already.

GroupDocs hosts all Java APIs on GroupDocs Artifact Repository, so simply configure your Maven project to fetch the dependencies automatically.

Add Text Watermark to PDF Pages

// Constants.InDocumentPdf is an absolute or relative path to your document. Ex: "C:\\Docs\\document.pdf"
Watermarker watermarker = new Watermarker(Constants.InDocumentPdf);                                      

TextWatermark watermark = new TextWatermark("top secret", new Font("Arial", 36));                        
watermark.setForegroundColor(Color.getRed());                                                            
watermark.setHorizontalAlignment(HorizontalAlignment.Center);                                            
watermark.setVerticalAlignment(VerticalAlignment.Center);                                                

watermarker.add(watermark);                                                                              
watermarker.save(Constants.OutDocumentPdf);                                                              

watermarker.close();        

Search Watermarks in PDF Document

// Constants.InDocumentPdf is an absolute or relative path to your document. Ex: "C:\\Docs\\document.pdf"
Watermarker watermarker = new Watermarker(Constants.InDocumentPdf);                                      

PossibleWatermarkCollection possibleWatermarks = watermarker.search();                                   
for (PossibleWatermark possibleWatermark : possibleWatermarks)                                           
{                                                                                                        
    if (possibleWatermark.getImageData() != null)                                                        
    {                                                                                                    
        System.out.println(possibleWatermark.getImageData().length);                                     
    }                                                                                                    

    System.out.println(possibleWatermark.getText());                                                     
    System.out.println(possibleWatermark.getX());                                                        
    System.out.println(possibleWatermark.getY());                                                        
    System.out.println(possibleWatermark.getRotateAngle());                                              
    System.out.println(possibleWatermark.getWidth());                                                    
    System.out.println(possibleWatermark.getHeight());                                                   
}                                                                                                        

watermarker.close();        

Home | Product Page | Documentation | Demos | API Reference | Examples | Blog | Search | Free Support | Temporary License