com.aspose.words

Class MsWordVersion

  • 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();
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 intWORD_2000 = 0
Optimize Aspose.Words behavior to match MS Word 2000 version.
static final intWORD_2002 = 1
Optimize Aspose.Words behavior to match MS Word 2002 version.
static final intWORD_2003 = 2
Optimize Aspose.Words behavior to match MS Word 2003 version.
static final intWORD_2007 = 3
Optimize Aspose.Words behavior to match MS Word 2007 version.
static final intWORD_2010 = 4
Optimize Aspose.Words behavior to match MS Word 2010 version.
static final intWORD_2013 = 5
Optimize Aspose.Words behavior to match MS Word 2013 version.
static final intWORD_2016 = 6
Optimize Aspose.Words behavior to match MS Word 2016 version.
static final intWORD_2019 = 7
Optimize Aspose.Words behavior to match MS Word 2019 version.
 

    • Field Detail

      • 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.
      • WORD_2019 = 7

        public static final int WORD_2019
        Optimize Aspose.Words behavior to match MS Word 2019 version.