public class MsWordVersion
Example:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.startTable();
builder.getRowFormat().setHeight(100.0);
builder.getRowFormat().setHeightRule(HeightRule.EXACTLY);
for (int i = 0; i < 31; i++) {
if (i != 0 && i % 7 == 0) builder.endRow();
builder.insertCell();
builder.write("Cell contents");
}
builder.endTable();
NodeCollection runs = doc.getChildNodes(NodeType.RUN, true);
int num = 1;
for (Run run : (Iterable<Run>) runs) {
Shape watermark = new Shape(doc, ShapeType.TEXT_PLAIN_TEXT);
watermark.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
watermark.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
// False - display the shape outside of table cell, True - display the shape outside of table cell
watermark.isLayoutInCell(true);
watermark.setWidth(30.0);
watermark.setHeight(30.0);
watermark.setHorizontalAlignment(HorizontalAlignment.CENTER);
watermark.setVerticalAlignment(VerticalAlignment.CENTER);
watermark.setRotation(-40);
watermark.getFill().setColor(new Color(220, 220, 220));
watermark.setStrokeColor(new Color(220, 220, 220));
watermark.getTextPath().setText(MessageFormat.format("{0}", num));
watermark.getTextPath().setFontFamily("Arial");
watermark.setName(MessageFormat.format("Watermark_{0}", num));
// Property will take effect only if the WrapType property is set to something other than WrapType.Inline
watermark.setWrapType(WrapType.NONE);
watermark.setBehindText(true);
builder.moveTo(run);
builder.insertNode(watermark);
num = num + 1;
}
// Behaviour of MS Word on working with shapes in table cells is changed in the last versions
// Adding the following line is needed to make the shape displayed in center of a page
doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2010);
doc.save(getArtifactsDir() + "Shape.LayoutInTableCell.docx");
Field Summary | ||
---|---|---|
static final int | WORD_2000 | |
Optimize Aspose.Words behavior to match MS Word 2000 version.
|
||
static final int | WORD_2002 | |
Optimize Aspose.Words behavior to match MS Word 2002 version.
|
||
static final int | WORD_2003 | |
Optimize Aspose.Words behavior to match MS Word 2003 version.
|
||
static final int | WORD_2007 | |
Optimize Aspose.Words behavior to match MS Word 2007 version.
|
||
static final int | WORD_2010 | |
Optimize Aspose.Words behavior to match MS Word 2010 version.
|
||
static final int | WORD_2013 | |
Optimize Aspose.Words behavior to match MS Word 2013 version.
|
||
static final int | WORD_2016 | |
Optimize Aspose.Words behavior to match MS Word 2016 version.
|
||
static final int | WORD_2019 | |
Optimize Aspose.Words behavior to match MS Word 2019 version.
|
public static final int WORD_2000
public static final int WORD_2002
public static final int WORD_2003
public static final int WORD_2007
public static final int WORD_2010
public static final int WORD_2013
public static final int WORD_2016
public static final int WORD_2019