Adding WordArt to Word Documents with Java

WordArt provides enhancedd visual appeal and emphasis compared to regular text, making it vaulable for document formatting. This guide demonstrates how to create and customize WordArt in Word documents using the Free Spire.Doc for Java library.

Library Installation

Add the Free Spire.Doc dependency to you're project via Maven:

<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <url>http://repo.e-iceblue.cn/repository/maven-public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.doc.free</artifactId>
        <version>2.7.3</version>
    </dependency>
</dependencies>

Creating WordArt

Here's a Java implementation for generating WordArt with custom styling:

import com.spire.doc.*;
import com.spire.doc.documents.*;
import com.spire.doc.fields.ShapeObject;
import java.awt.*;

public class DocumentStyling {
    public static void main(String[] args) throws Exception {
        // Initialize document
        Document document = new Document();
        
        // Create document section
        Section docSection = document.addSection();
        
        // Add paragraph container
        Paragraph textParagraph = docSection.addParagraph();
        
        // Create WordArt shape
        ShapeObject artShape = textParagraph.appendShape(300, 85, ShapeType.Text_Inflate);
        
        // Position configuration
        artShape.setVerticalPosition(120);
        artShape.setHorizontalPosition(150);
        
        // Set WordArt content
        artShape.getWordArt().setText("Ocean Sunrise");
        
        // Apply color styling
        artShape.setFillColor(Color.BLUE);
        artShape.setStrokeColor(Color.DARK_GRAY);
        
        // Save output
        document.saveToFile("styledDocument.docx", FileFormat.Docx_2013);
    }
}

The code creates a Word document with inflated text styling, positioned at specified coordinates with custom color fill and outline.

Tags: java Spire.Doc WordArt Document Processing Word Documents

Posted on Mon, 11 May 2026 02:00:23 +0000 by alego