PPTX DOCX XLSX PDF ODP
  Product Family
DOCX

Add Text Watermark to DOCX via Java

Build your own Java apps to watermark Microsoft Word DOCX files using server-side APIs.

How to Watermark DOCX File Using Java

In order to watermark Micrososft Word DOCX file, we’ll use

Aspose.Words for Java

API which is a feature-rich, powerful and easy to use warermarking API for Java platform. You can download its latest version directly from

Maven

and install it within your Maven-based project by adding the following configurations to the pom.xml.

Repository


<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>

Dependency

<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>version of aspose-words API</version>
<classifier>jdk17</classifier>
</dependency>

Steps to Add Watermark to DOCX via Java

  1. Load DOCX file with an instance of Document
  2. Create an instance of TextWatermarkOptions and set its properties
  3. Call Watermark.setText method and pass watermark text & object of TextWatermarkOptions
  4. Save the document with text watermark

System Requirements

Before integrating the code, make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with Java Runtime Environment for JSP/JSF Application and Desktop Applications.
  • Get latest version of Aspose.Words for Java directly from Maven.
 

Add Watermark to DOCX - Java


//adding text watermark
Document docx = new Document(dataDir + "Document.docx");

TextWatermarkOptions options = new TextWatermarkOptions();
options.setFontFamily("Arial");
options.setFontSize(36);
options.setColor(Color.BLACK);
options.setLayout(WatermarkLayout.HORIZONTAL);
options.isSemitrasparent(false);

docx.getWatermark().setText("Test", options);

docx.save(dataDir + "AddTextWatermark_out.docx");

// similarly adding image watermark is with just few lines of code  
 
  • Java Words API can be used to load, view and convert Microsoft Word and OpenDocument Formats like DOC, DOCX, ODT to PDF, XPS, HTML and various other formats. You can also create new documents from scratch and save them in the supported formats. It is a standalone API that is suitable for server side and backend systems where high performance is required. It does not depend on any software like Microsoft or OpenOffice. ‎

    Watermark DOCX via Online App

    Other Supported Watermarking Formats

    Using Java, one can easily watermark different formats including.

    DOC (Microsoft Word Binary Format)
    DOT (Microsoft Word Template Files)
    DOTX (Microsoft Word Template File)
    ODT (OpenDocument Text File Format)
    OTT (OpenDocument Standard Format)
    RTF (Rich Text Format)