java.lang.Object
com.aspose.words.MsWordVersion
public class MsWordVersion
- extends java.lang.Object
Utility class containing constants.
Allows Aspose.Wods to mimic MS Word version-specific application behavior.
Example:
Shows how to display the shape, inside a table or outside of it.
Document doc = new Document(getMyDir() + "Shape.LayoutInCell.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
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);
watermark.isLayoutInCell(true); // False - display the shape outside of table cell, True - display the shape outside of table cell
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}", UUID.randomUUID()));
// 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.LayoutInCell.docx");
Field Summary |
static final int | WORD_2000 = 0 | |
Optimize Aspose.Words behavior to match MS Word 2000 version.
|
static final int | WORD_2002 = 1 | |
Optimize Aspose.Words behavior to match MS Word 2002 version.
|
static final int | WORD_2003 = 2 | |
Optimize Aspose.Words behavior to match MS Word 2003 version.
|
static final int | WORD_2007 = 3 | |
Optimize Aspose.Words behavior to match MS Word 2007 version.
|
static final int | WORD_2010 = 4 | |
Optimize Aspose.Words behavior to match MS Word 2010 version.
|
static final int | WORD_2013 = 5 | |
Optimize Aspose.Words behavior to match MS Word 2013 version.
|
static final int | WORD_2016 = 6 | |
Optimize Aspose.Words behavior to match MS Word 2016 version.
|
WORD_2000 = 0 | |
public static final int WORD_2000 |
-
Optimize Aspose.Words behavior to match MS Word 2000 version.
WORD_2002 = 1 | |
public static final int WORD_2002 |
-
Optimize Aspose.Words behavior to match MS Word 2002 version.
WORD_2003 = 2 | |
public static final int WORD_2003 |
-
Optimize Aspose.Words behavior to match MS Word 2003 version.
WORD_2007 = 3 | |
public static final int WORD_2007 |
-
Optimize Aspose.Words behavior to match MS Word 2007 version.
WORD_2010 = 4 | |
public static final int WORD_2010 |
-
Optimize Aspose.Words behavior to match MS Word 2010 version.
WORD_2013 = 5 | |
public static final int WORD_2013 |
-
Optimize Aspose.Words behavior to match MS Word 2013 version.
WORD_2016 = 6 | |
public static final int WORD_2016 |
-
Optimize Aspose.Words behavior to match MS Word 2016 version.
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.