Compared to regular text, WordArt looks more beautiful and interesting, but is designed to be easy to sort out and is often found in magazines and posters. In your daily work, when you edit a Word document, you can make articles stand out and beautify your page layout through WordArt. In this article, I'll show you how to use Free Spire.Doc for Java to add WordArt to your word document and set styles and effects.
** Import JAR package ** ** Method 1: ** After downloading and unzipping Free Spire.Doc for Java, in the lib folder Import the Spire.Doc.jar package into your Java application as a dependency.
** Method 2: ** After installing the JAR package directly from the Maven repository, configure the pom.xml file as follows:
<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.doc.free</artifactId>
<version>3.9.0</version>
</dependency>
</dependencies>
** Add WordArt **
import com.spire.doc.*;
import com.spire.doc.documents.*;
import com.spire.doc.fields.ShapeObject;
import java.awt.*;
public class WordArt{
public static void main(String[] args) throws Exception {
//Create a word document
Document doc = new Document();
//Add section
Section section = doc.addSection();
//Add paragraph to section
Paragraph paragraph = section.addParagraph();
//Add a shape and set its size and style
ShapeObject shape = paragraph.appendShape(280, 80, ShapeType.Text_Inflate);
//Set the position of the shape
shape.setVerticalPosition(80);
shape.setHorizontalPosition(100);
//WordArt text content
shape.getWordArt().setText("The influence of words");
//Sets the color of the WordArt fill
shape.setFillColor(Color.CYAN);
shape.setStrokeColor(Color.BLACK);
//Save the document
doc.saveToFile("WordArt.docx", FileFormat.Docx_2013);
}
}
** Add WordArt effects **
Recommended Posts