Document mainDoc = new Document(wordPathUrl);
// 获取文档中的所有形状
NodeCollection<Shape> shapes = mainDoc.getChildNodes(NodeType.SHAPE, true);
// 遍历每个形状
for (Shape shape : shapes) {
// 检查是否为艺术字(文本框)
if (shape.getTextPath() != null && StringUtils.isNotEmpty(shape.getTextPath().getText())) {
System.out.println(shape.getTextPath().getText());
// 获取艺术字中的文本框架
shape.getTextPath().setFontFamily("Arial");
shape.getTextPath().setText("测试测试");
}
}