Share via


Anchor Class

Anchor for Floating DrawingML Object.When the object is serialized out as xml, its qualified name is wp:anchor.

Inheritance Hierarchy

System.Object
  DocumentFormat.OpenXml.OpenXmlElement
    DocumentFormat.OpenXml.OpenXmlCompositeElement
      DocumentFormat.OpenXml.Drawing.Wordprocessing.Anchor

Namespace:  DocumentFormat.OpenXml.Drawing.Wordprocessing
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)

Syntax

'Declaration
<ChildElementInfoAttribute(GetType(Graphic))> _
<ChildElementInfoAttribute(GetType(WrapTopBottom))> _
<ChildElementInfoAttribute(GetType(EffectExtent))> _
<ChildElementInfoAttribute(GetType(WrapNone))> _
<ChildElementInfoAttribute(GetType(SimplePosition))> _
<ChildElementInfoAttribute(GetType(HorizontalPosition))> _
<ChildElementInfoAttribute(GetType(VerticalPosition))> _
<ChildElementInfoAttribute(GetType(Extent))> _
<ChildElementInfoAttribute(GetType(WrapSquare))> _
<ChildElementInfoAttribute(GetType(WrapTight))> _
<ChildElementInfoAttribute(GetType(WrapThrough))> _
<ChildElementInfoAttribute(GetType(DocProperties))> _
<ChildElementInfoAttribute(GetType(NonVisualGraphicFrameDrawingProperties))> _
<ChildElementInfoAttribute(GetType(RelativeWidth), FileFormatVersions.Office2010)> _
<ChildElementInfoAttribute(GetType(RelativeHeight), FileFormatVersions.Office2010)> _
Public Class Anchor _
    Inherits OpenXmlCompositeElement
'Usage
Dim instance As Anchor
[ChildElementInfoAttribute(typeof(Graphic))]
[ChildElementInfoAttribute(typeof(WrapTopBottom))]
[ChildElementInfoAttribute(typeof(EffectExtent))]
[ChildElementInfoAttribute(typeof(WrapNone))]
[ChildElementInfoAttribute(typeof(SimplePosition))]
[ChildElementInfoAttribute(typeof(HorizontalPosition))]
[ChildElementInfoAttribute(typeof(VerticalPosition))]
[ChildElementInfoAttribute(typeof(Extent))]
[ChildElementInfoAttribute(typeof(WrapSquare))]
[ChildElementInfoAttribute(typeof(WrapTight))]
[ChildElementInfoAttribute(typeof(WrapThrough))]
[ChildElementInfoAttribute(typeof(DocProperties))]
[ChildElementInfoAttribute(typeof(NonVisualGraphicFrameDrawingProperties))]
[ChildElementInfoAttribute(typeof(RelativeWidth), FileFormatVersions.Office2010)]
[ChildElementInfoAttribute(typeof(RelativeHeight), FileFormatVersions.Office2010)]
public class Anchor : OpenXmlCompositeElement

Remarks

The following table lists the possible child types:

  • SimplePosition <wp:simplePos>

  • HorizontalPosition <wp:positionH>

  • VerticalPosition <wp:positionV>

  • Extent <wp:extent>

  • EffectExtent <wp:effectExtent>

  • WrapNone <wp:wrapNone>

  • WrapSquare <wp:wrapSquare>

  • WrapTight <wp:wrapTight>

  • WrapThrough <wp:wrapThrough>

  • WrapTopBottom <wp:wrapTopAndBottom>

  • DocProperties <wp:docPr>

  • NonVisualGraphicFrameDrawingProperties <wp:cNvGraphicFramePr>

  • DocumentFormat.OpenXml.Drawing.Graphic <a:graphic>

  • DocumentFormat.OpenXml.Office2010.Word.Drawing.RelativeWidth <wp14:sizeRelH>

  • DocumentFormat.OpenXml.Office2010.Word.Drawing.RelativeHeight <wp14:sizeRelV>

[ISO/IEC 29500-1 1st Edition]

20.4.2.3 anchor (Anchor for Floating DrawingML Object)

This element specifies that the DrawingML object located at this position in the document is a floating object. Within a WordprocessingML document, drawing objects can exist in two states:

  • Inline - The drawing object is in line with the text, and affects the line height and layout of its line (like a character glyph of similar size).

  • Floating - The drawing object is anchored within the text, but can be absolutely positioned in the document relative to the page.

When this element encapsulates the DrawingML object's information, then all child elements shall dictate the positioning of this object as a floating object on the page.

[Example: Consider a WordprocessingML document where the anchor for a floating DrawingML object must be the first piece of run content within a paragraph. That paragraph's content would be specified as follows:

<w:p>
<w:r>
<w:drawing>
<wp:anchor … >
…
</wp:anchor>
</w:drawing>
</w:r>
</w:p>

The anchor element, when present as the child element of the drawing element, specifies that this DrawingML object must be positioned as a floating object based on the values of its child elements. end example]

Parent Elements

drawing (§17.3.3.9)

Child Elements

Subclause

cNvGraphicFramePr (Common DrawingML Non-Visual Properties)

§20.4.2.4

docPr (Drawing Object Non-Visual Properties)

§20.4.2.5

effectExtent (Object Extents Including Effects)

§20.4.2.6

extent (Drawing Object Size)

§20.4.2.7

graphic (Graphic Object)

§20.1.2.2.16

positionH (Horizontal Positioning)

§20.4.2.10

positionV (Vertical Positioning)

§20.4.2.11

simplePos (Simple Positioning Coordinates)

§20.4.2.13

wrapNone (No Text Wrapping)

§20.4.2.15

wrapSquare (Square Wrapping)

§20.4.2.17

wrapThrough (Through Wrapping)

§20.4.2.18

wrapTight (Tight Wrapping)

§20.4.2.19

wrapTopAndBottom (Top and Bottom Wrapping)

§20.4.2.20

Attributes

Description

allowOverlap (Allow Objects to Overlap)

Specifies whether a DrawingML object which intersects another DrawingML object at display time is allowed to overlap the contents of the other DrawingML object. If a DrawingML object cannot overlap other DrawingML object, it shall be repositioned when displayed to prevent this overlap as needed.

If this element is omitted on a given DrawingML object, then overlap shall not be allowed between a DrawingML object which intersects another DrawingML object displayed at the same location.

[Example: Consider a document with two DrawingML objects which are allowed to overlap each other. This would be specified as follows within each object's anchor markup:

<wp:anchor allowOverlap="true" … >
  …
</wp:anchor>

The allowOverlap attribute has a value of true, which specifies that this object must be allowed to overlap other objects when it is displayed on the document. end example]

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.

behindDoc (Display Behind Document Text)

Specifies whether this floating DrawingML object is displayed behind the text of the document when the document is displayed. When a DrawingML object is displayed within a WordprocessingML document, that object can intersect with text in the document. This attribute shall determine whether the text or the object is rendered on top in case of overlapping.

If this attribute is omitted, then the parent DrawingML object shall be displayed in front of the text content of the document in cases of overlapping.

[Example: Consider a floating DrawingML object which must be displayed above any text which it intersects within the document's content. This setting would be specified as follows:

<wp:anchor behindDoc="false" … >
…
</wp:anchor>

The behindDoc attribute has a value of false, which specifies that the DrawingML object is displayed above the text of the document in z-order. end example]

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.

distB (Distance From Text on Bottom Edge)

Specifies the minimum distance which shall be maintained between the bottom edge of this drawing object and any subsequent text within the document when this graphical object is displayed within the document's contents.

The distance shall be measured in EMUs (English Metric Units).

If this object is an inline object (i.e. has a parent element of inline), then this value shall not have any effect when displaying the object in line with text, but can be maintained and used if the object is subsequently changed to floating. If the wrapping element [Example: wrapThrough or wrapSquare end example] present as a child element also has a distance from text, then this value shall be ignored.

[Example: Consider a floating DrawingML object which must have one-half of an inch of padding between its bottom edge and the nearest text. This setting would be specified as follows:

<wp:anchor distB="457200" … >
…
</wp:anchor>

The distB attribute specifies that the padding distance must be 457200 EMUs or one-half of an inch. end example]

The possible values for this attribute are defined by the ST_WrapDistance simple type (§20.4.3.6).

distL (Distance From Text on Left Edge)

Specifies the minimum distance which shall be maintained between the left edge of this drawing object and any subsequent text within the document when this graphical object is displayed within the document's contents.

The distance shall be measured in EMUs (English Metric Units).

If this object is an inline object (i.e. has a parent element of inline), then this value shall not have any effect when displaying the object in line with text, but can be maintained and used if the object is subsequently changed to floating. If the wrapping element [Example: wrapThrough or wrapSquare end example] present as a child element also has a distance from text, then this value shall be ignored.

[Example: Consider a floating DrawingML object which must have one-quarter of an inch of padding between its left edge and the nearest text. This setting would be specified as follows:

<wp:anchor distL="228600" … >
…
</wp:anchor>

The distL attribute specifies that the padding distance must be 228600 EMUs or one-quarter of an inch. end example]

The possible values for this attribute are defined by the ST_WrapDistance simple type (§20.4.3.6).

distR (Distance From Text on Right Edge)

Specifies the minimum distance which shall be maintained between the right edge of this drawing object and any subsequent text within the document when this graphical object is displayed within the document's contents.

The distance shall be measured in EMUs (English Metric Units).

If this object is an inline object (i.e. has a parent element of inline), then this value shall not have any effect when displaying the object in line with text, but can be maintained and used if the object is subsequently changed to floating. If the wrapping element [Example: wrapThrough or wrapSquare end example] present as a child element also has a distance from text, then this value shall be ignored.

[Example: Consider a floating DrawingML object which must have one-quarter of an inch of padding between its right edge and the nearest text. This setting would be specified as follows:

<wp:anchor distR="228600" … >
…
</wp:anchor>

The distR attribute specifies that the padding distance must be 228600 EMUs or one-quarter of an inch. end example]

The possible values for this attribute are defined by the ST_WrapDistance simple type (§20.4.3.6).

distT (Distance From Text on Top Edge)

Specifies the minimum distance which shall be maintained between the top edge of this drawing object and any subsequent text within the document when this graphical object is displayed within the document's contents.

The distance shall be measured in EMUs (English Metric Units).

If this object is an inline object (i.e. has a parent element of inline), then this value shall not have any effect when displaying the object in line with text, but can be maintained and used if the object is subsequently changed to floating. If the wrapping element [Example: wrapThrough or wrapSquare end example] present as a child element also has a distance from text, then this value shall be ignored.

[Example: Consider a floating DrawingML object which must have one-half of an inch of padding between its top edge and the nearest text. This setting would be specified as follows:

<wp:anchor distT="457200" … >
…
</wp:anchor>

The distT attribute specifies that the padding distance must be 457200 EMUs or one-half of an inch. end example]

The possible values for this attribute are defined by the ST_WrapDistance simple type (§20.4.3.6).

hidden (Hidden)

Specifies whether this floating DrawingML object is displayed. When a DrawingML object is displayed within a WordprocessingML document, that object can be hidden (i.e. present, but not visible). This attribute shall determine whether the object is rendered or made hidden. [Note: An application can have settings which allow this object to be viewed. end note]

If this attribute is omitted, then the parent DrawingML object shall be displayed (i.e. not hidden).

[Example: Consider a floating DrawingML object which must be hidden within the document's content. This setting would be specified as follows:

<wp:anchor hidden="true" … >
…
</wp:anchor>

The hidden attribute has a value of true, which specifies that the DrawingML object is hidden and not displayed when the document is displayed. end example]

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.

layoutInCell (Layout In Table Cell)

Specifies how this DrawingML object behaves when its anchor is located in a table cell; and its specified position would cause it to intersect with a table cell displayed in the document. That behavior shall be as follows:

  • When this attribute has a value of true, then the object shall be positioned within the existing table cell, causing the cell to be resized as needed. This means that all positioning shall be relative to the cell and not the line on which the table appears.

  • When this attribute has a value of false, then the object shall be positioned as specified, but the table shall be resized and/or relocated within the document as needed to accommodate the object. This means that all positioning shall be relative to the line on which the table appears and not the cell in which the anchor is present.

If this attribute is omitted, then its default value shall be considered to be false.

[Example: Consider a DrawingML picture which must be displayed in the center of the document. If the object is contained within a table and is defined as follows:

<wp:anchor layoutInCell="true" … >
…
</wp:anchor>

The layoutInCell attribute has a value of true, which specifies that the object can be placed within the cell if needed, for example:

DocumentFormat.OpenXml.Drawing.Wordprocessing.Anch

If the layoutInCell attribute was now set to false, the object must be laid out outside of the cell, causing the table to be repositioned:

DocumentFormat.OpenXml.Drawing.Wordprocessing.Anch

end example]

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.

locked (Lock Anchor)

Specifies that the anchor location for this object shall not be modified at runtime when an application edits the contents of this document. [Guidance: An application might have automatic behaviors which reposition the anchor for a DrawingML object based on user interaction - for example, moving it from one page to another as needed. This element must tell applications not to perform any such behaviors. end guidance]

If this attribute is omitted, then the anchor shall not be locked for the parent DrawingML object (i.e. a default value of false).

[Example: Consider a floating DrawingML object which must have its anchor locked at the current location. This setting would be specified as follows:

<wp:anchor locked="true" … >
…
</wp:anchor>

The locked attribute has a value of true, which specifies that the DrawingML object's current anchor location must not be changed by applications editing this content. end example]

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.

relativeHeight (Relative Z-Ordering Position)

Specifies the relative Z-ordering of all DrawingML objects in this document. Each floating DrawingML object shall have a Z-ordering value, which determines which object is displayed when any two objects intersect. Higher values shall indicate higher Z-order; lower values shall indicate lower Z-order.

This attribute shall only indicate the Z-order with respect to other objects in the document which have an identical behindDoc attribute value. All objects with a behindDoc value of false shall be displayed above elements with a value of true.

[Example: Consider two floating DrawingML objects as follows:

<wp:anchor relativeHeight="5" … >
…
</wp:anchor>
…
<wp:anchor relativeHeight="8" … >
…
</wp:anchor>

The relativeHeight attribute of the second object is 8, which specifies that the second DrawingML object must be at a higher Z-order than the first and must be displayed whenever the two overlap. end example]

The possible values for this attribute are defined by the W3C XML Schema unsignedInt datatype.

simplePos (Page Positioning)

Specifies that this object shall be positioned using the positioning information in the simplePos child element (§20.4.2.13). This positioning, when specified, positions the object on the page by placing its top left point at the x-y coordinates specified by that element.

If this element is omitted, then this object shall not use the simple positioning information in the simplePos element, even when present.

[Example: Consider a floating DrawingML object which must be positioned at the top left corner of the page using simple positioning. This setting would be specified as follows:

<wp:anchor simplePos="true" … >
<wp:simplePos x="0" y="0" />
  …
</wp:anchor>

The simplePos attribute has a value of true, which specifies that the DrawingML object's current position must be dictated by the simplePos element, and hence placed at 0,0. end example]

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.

[Note: The W3C XML Schema definition of this element’s content model (CT_Anchor) is located in §A.4.4. end note]

© ISO/IEC29500: 2008.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Anchor Members

DocumentFormat.OpenXml.Drawing.Wordprocessing Namespace