Class OoxmlCompliance

  • java.lang.Object
    • com.aspose.words.OoxmlCompliance
public class OoxmlCompliance 
extends java.lang.Object

Utility class containing constants. Allows to specify which OOXML specification will be used when saving in the DOCX format.


Shows how to insert DML shapes into a document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Below are two wrapping types that shapes may have.
// 1 -  Floating:
builder.insertShape(ShapeType.TOP_CORNERS_ROUNDED, RelativeHorizontalPosition.PAGE, 100.0,
        RelativeVerticalPosition.PAGE, 100.0, 50.0, 50.0, WrapType.NONE);

// 2 -  Inline:
builder.insertShape(ShapeType.DIAGONAL_CORNERS_ROUNDED, 50.0, 50.0);

// If you need to create "non-primitive" shapes, such as SingleCornerSnipped, TopCornersSnipped, DiagonalCornersSnipped,
// TopCornersOneRoundedOneSnipped, SingleCornerRounded, TopCornersRounded, or DiagonalCornersRounded,
// then save the document with "Strict" or "Transitional" compliance, which allows saving shape as DML.
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.DOCX);
saveOptions.setCompliance(OoxmlCompliance.ISO_29500_2008_TRANSITIONAL); + "Shape.ShapeInsertion.docx", saveOptions);


Shows how to configure a list to restart numbering at each section.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);


List list = doc.getLists().get(0);

// The "IsRestartAtEachSection" property will only be applicable when
// the document's OOXML compliance level is to a standard that is newer than "OoxmlComplianceCore.Ecma376".
OoxmlSaveOptions options = new OoxmlSaveOptions();


builder.writeln("List item 1");
builder.writeln("List item 2");
builder.writeln("List item 3");
builder.writeln("List item 4"); + "OoxmlSaveOptions.RestartingDocumentList.docx", options);

doc = new Document(getArtifactsDir() + "OoxmlSaveOptions.RestartingDocumentList.docx");

Assert.assertEquals(restartListAtEachSection, doc.getLists().get(0).isRestartAtEachSection());


Shows how to set an OOXML compliance specification for a saved document to adhere to.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// If we configure compatibility options to comply with Microsoft Word 2003,
// inserting an image will define its shape using VML.
builder.insertImage(getImageDir() + "Transparent background logo.png");

Assert.assertEquals(ShapeMarkupLanguage.VML, ((Shape) doc.getChild(NodeType.SHAPE, 0, true)).getMarkupLanguage());

// The "ISO/IEC 29500:2008" OOXML standard does not support VML shapes.
// If we set the "Compliance" property of the SaveOptions object to "OoxmlCompliance.Iso29500_2008_Strict",
// any document we save while passing this object will have to follow that standard. 
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.setSaveFormat(SaveFormat.DOCX); + "OoxmlSaveOptions.Iso29500Strict.docx", saveOptions);

// Our saved document defines the shape using DML to adhere to the "ISO/IEC 29500:2008" OOXML standard.
doc = new Document(getArtifactsDir() + "OoxmlSaveOptions.Iso29500Strict.docx");

Assert.assertEquals(ShapeMarkupLanguage.DML, ((Shape) doc.getChild(NodeType.SHAPE, 0, true)).getMarkupLanguage());

Field Summary
static final intECMA_376_2006 = 0
ECMA-376 1st Edition, 2006.
static final intISO_29500_2008_TRANSITIONAL = 1
ISO/IEC 29500:2008 Transitional compliance level.
static final intISO_29500_2008_STRICT = 2
ISO/IEC 29500:2008 Strict compliance level.

    • Field Detail

      • ECMA_376_2006 = 0

        public static final int ECMA_376_2006
        ECMA-376 1st Edition, 2006.
      • ISO_29500_2008_TRANSITIONAL = 1

        public static final int ISO_29500_2008_TRANSITIONAL
        ISO/IEC 29500:2008 Transitional compliance level.
      • ISO_29500_2008_STRICT = 2

        public static final int ISO_29500_2008_STRICT
        ISO/IEC 29500:2008 Strict compliance level.