PPTX DOCX XLSX PDF ODP
  Product Family
ODT

Add Text Watermark to ODT via Java

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

How to Watermark ODT File Using Java

In order to watermark Micrososft Word ODT 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 ODT via Java

  1. Load ODT 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 ODT - Java


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

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

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

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

// 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 ODT via Online App

    Other Supported Watermarking Formats

    Using Java, one can easily watermark different formats including.

    DOC (Microsoft Word Binary Format)
    DOCX (Office 2007+ Words Document)
    DOT (Microsoft Word Template Files)
    DOTX (Microsoft Word Template File)
    OTT (OpenDocument Standard Format)
    RTF (Rich Text Format)