a:xfrm (2D Transform)
Specifies the 2D position, size, rotation, and flip properties of a shape in DrawingML.
Description
\:xfrm\ is the DrawingML element that defines 2D transformations (position, size, rotation, flipping) for shapes. It is defined in ECMA-376 Part 1 §20.1.7.5.
2D transforms are fundamental to shape geometry and are used for:
- Positioning shapes at specific coordinates
- Sizing shapes to exact dimensions
- Rotating shapes by specific angles
- Flipping shapes horizontally or vertically
- Defining child coordinate systems in groups
- Creating precise layout and positioning
The \:xfrm\ element contains:
- Offset (\:off) — X, Y position
- Extents (\:ext) — Width, height
- Optional: Flip flags (flipH, flipV) and rotation (rot)
- For groups: Child offset (\:chOff) and child extents (\:chExt)
Attributes
| Attribute | Type | Range | Default | Description |
|---|---|---|---|---|
| \ | ||||
| ot\ | Integer | -180°–180° (EMUs) | 0 | Rotation angle in 1/60,000 of a degree. Positive = counter-clockwise. |
| \lipH\ | Boolean | true, false | false | Flip shape horizontally (mirror left-right). |
| \lipV\ | Boolean | true, false | false | Flip shape vertically (mirror top-bottom). |
Note: Rotation is stored in 1/60,000° units (e.g., 5400000 = 90°).
Content Model
\:xfrm\ structure:
- a:off (required, 1) — Offset (position) of shape
- a:ext (required, 1) — Extents (size) of shape
- a:chOff (optional, 0–1) — Child offset (for groups only)
- a:chExt (optional, 0–1) — Child extents (for groups only)
Child Elements Table
| Element | Occurrence | Description |
|---|---|---|
| \:off\ | 1 (required) | Offset: x, y position in EMUs |
| \:ext\ | 1 (required) | Extents: cx (width), cy (height) in EMUs |
| \:chOff\ | 0–1 (optional) | Child offset for coordinate system; group shapes only |
| \:chExt\ | 0–1 (optional) | Child extents for coordinate system; group shapes only |
Examples
Basic Shape Positioning and Sizing
<a:xfrm>
<a:off x="1000000" y="1000000"/>
<a:ext cx="5000000" cy="3000000"/>
</a:xfrm>
using DocumentFormat.OpenXml.Drawing;
var transform = new Transform2D();
transform.Append(new Offset { X = 1000000, Y = 1000000 });
transform.Append(new Extents { Cx = 5000000, Cy = 3000000 });
// Attach to shape properties
var spPr = new ShapeProperties();
spPr.Append(transform);
Rotated Shape (90 Degrees)
<a:xfrm rot="5400000">
<a:off x="2000000" y="2000000"/>
<a:ext cx="3000000" cy="2000000"/>
</a:xfrm>
var transform = new Transform2D { Rotation = 5400000 }; // 90°
transform.Append(new Offset { X = 2000000, Y = 2000000 });
transform.Append(new Extents { Cx = 3000000, Cy = 2000000 });
Horizontally Flipped Shape
<a:xfrm flipH="1">
<a:off x="1500000" y="1500000"/>
<a:ext cx="4000000" cy="2500000"/>
</a:xfrm>
var transform = new Transform2D { HorizontalFlip = true };
transform.Append(new Offset { X = 1500000, Y = 1500000 });
transform.Append(new Extents { Cx = 4000000, Cy = 2500000 });
Vertically Flipped and Rotated
<a:xfrm rot="2700000" flipV="1">
<a:off x="2000000" y="2000000"/>
<a:ext cx="3000000" cy="2000000"/>
</a:xfrm>
var transform = new Transform2D
{
Rotation = 2700000, // -90° (270° counter-clockwise)
VerticalFlip = true
};
transform.Append(new Offset { X = 2000000, Y = 2000000 });
transform.Append(new Extents { Cx = 3000000, Cy = 2000000 });
Group Shape with Child Coordinate System
<a:grpSpPr>
<a:xfrm>
<!-- Group position and size -->
<a:off x="0" y="0"/>
<a:ext cx="10000000" cy="8000000"/>
<!-- Child coordinate system (defines local coordinates for children) -->
<a:chOff x="0" y="0"/>
<a:chExt cx="10000000" cy="8000000"/>
</a:xfrm>
</a:grpSpPr>
var grpSpPr = new GroupShapeProperties();
var transform = new Transform2D();
// Group position and size
transform.Append(new Offset { X = 0, Y = 0 });
transform.Append(new Extents { Cx = 10000000, Cy = 8000000 });
// Child coordinate system
transform.Append(new ChildOffset { X = 0, Y = 0 });
transform.Append(new ChildExtents { Cx = 10000000, Cy = 8000000 });
grpSpPr.Append(transform);
Scaled Group (Child Scaling)
<a:grpSpPr>
<a:xfrm>
<!-- Group occupies 10M × 8M on slide -->
<a:off x="1000000" y="1000000"/>
<a:ext cx="10000000" cy="8000000"/>
<!-- But children use 5M × 4M coordinate space (2× scaling) -->
<a:chOff x="0" y="0"/>
<a:chExt cx="5000000" cy="4000000"/>
</a:xfrm>
</a:grpSpPr>
var grpSpPr = new GroupShapeProperties();
var transform = new Transform2D();
// Group displayed at 10M × 8M
transform.Append(new Offset { X = 1000000, Y = 1000000 });
transform.Append(new Extents { Cx = 10000000, Cy = 8000000 });
// Children in 5M × 4M space → automatically scaled 2×
transform.Append(new ChildOffset { X = 0, Y = 0 });
transform.Append(new ChildExtents { Cx = 5000000, Cy = 4000000 });
grpSpPr.Append(transform);
Rotation Reference
Rotation values are in 1/60,000° units:
| Degrees | EMU Value | Notes |
|---|---|---|
| 0° | 0 | No rotation |
| 45° | 2700000 | Quarter rotation |
| 90° | 5400000 | Right angle |
| 135° | 8100000 | Three-quarter |
| 180° | 10800000 | Full flip |
| -45° | -2700000 | Negative = clockwise |
| -90° | -5400000 | Clockwise right angle |
Formula: EMU = Degrees × 60000
Position and Size Units
Dimensions in \:xfrm\ use English Metric Units (EMUs):
| Unit | EMU Value | Notes |
|---|---|---|
| 1 inch | 914400 | Standard screen DPI |
| 1 cm | 360000 | Metric unit |
| 1 mm | 36000 | Millimeter |
| 1 point | 12700 | Typographic point |
| 1 pixel | 9525 | Screen pixel (96 DPI) |
Coordinate System: Origin (0,0) at top-left; X increases right, Y increases down.
Transform Properties
Flip Combinations
| flipH | flipV | Result |
|---|---|---|
| false | false | No flip (normal) |
| true | false | Mirror left-right (horizontal) |
| false | true | Mirror top-bottom (vertical) |
| true | true | 180° rotation equivalent |
Group Child Coordinate System
Groups define local coordinate spaces for children:
` Parent (Slide) Coordinates: 10M × 8M ↓ Group Transform (a:grpSpPr/a:xfrm) ↓ Child Coordinate Space (a:chOff/a:chExt): 5M × 4M ↓ Children positioned in local 5M × 4M space ↓ Automatically scaled 2× to fill 10M × 8M group area `
This enables:
- Nested scaling: Children scale with group resize
- Local coordinates: Children use simple child space, not absolute coordinates
- Responsive design: Resize group, children auto-scale
Common Patterns
Centered Shape
xml
<!-- Center 4M × 3M shape on 10M × 8M canvas -->
<a:xfrm>
<a:off x="3000000" y="2500000"/>
<a:ext cx="4000000" cy="3000000"/>
</a:xfrm>
Full-Screen Shape
xml
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="9144000" cy="6858000"/>
</a:xfrm>
Rotated Text Box (45°)
xml
<a:xfrm rot="2700000">
<a:off x="1000000" y="1000000"/>
<a:ext cx="4000000" cy="2000000"/>
</a:xfrm>
Notes
Element Characteristics
- Required in all shapes: Every shape must have \:xfrm\
- Child extents (group-only): Define coordinate system for child shapes
- Rotation is global: Applied after position/size; origin at shape center
- Flipping: Applied independently; both can be set simultaneously
- Immutable in edit: Most Office apps recalculate on resize/rotate
Coordinate System Details
- Origin (0,0) at top-left of parent/slide
- X increases rightward
- Y increases downward
- Negative coordinates allowed (off-canvas positioning)
- Rotation origin: Shape center
Rendering
- Word: Position and size follow \:xfrm\ exactly
- PowerPoint: Animations/interactions respect transform
- Excel: Limited rotation support (some older versions)
- Publisher: Full transform support
Interaction with Shape Geometry
- Transform applies to bounding box (not geometry path)
- Shape geometry is relative to bounding box
- Combined: geometry + transform = final rendered shape
Best Practices
- Use EMU values consistently throughout document
- Store rotation angle separately for easy conversion
- For groups, define child extents for proper scaling
- Avoid extreme rotations (>180°); use -180° to 180° range
- Consider accessibility; rotated/flipped text may affect readability
- Document coordinate systems for complex grouped designs