The following code snippet positions a floating picture by specifying the Shape.Offset from the top and left margins. To allow absolute positioning, the Shape.HorizontalAlignment and Shape.VerticalAlignment properties should be set to None.
This example moves a floating object to a position where its upper left corner is located at 4.5 cm to the right of the left margin and 2 cm below the top margin.
Shapes.cs |
document.LoadDocument("Grimm.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml);
document.Unit = DevExpress.Office.DocumentUnit.Centimeter;
Shape myPicture = document.Shapes[1];
myPicture.HorizontalAlignment = ShapeHorizontalAlignment.None;
myPicture.VerticalAlignment = ShapeVerticalAlignment.None;
myPicture.RelativeHorizontalPosition = ShapeRelativeHorizontalPosition.LeftMargin;
myPicture.RelativeVerticalPosition = ShapeRelativeVerticalPosition.TopMargin;
myPicture.Offset = new System.Drawing.PointF(4.5f, 2.0f);
|
Shapes.vb |
document.LoadDocument("Grimm.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml)
document.Unit = DevExpress.Office.DocumentUnit.Centimeter
Dim myPicture As Shape = document.Shapes(1)
' Clear the qualitative positioning to allow positioning by specifying the numerical offset.
myPicture.HorizontalAlignment = ShapeHorizontalAlignment.None
myPicture.VerticalAlignment = ShapeVerticalAlignment.None
' Specify the reference item for positioning.
myPicture.RelativeHorizontalPosition = ShapeRelativeHorizontalPosition.LeftMargin
myPicture.RelativeVerticalPosition = ShapeRelativeVerticalPosition.TopMargin
' Specify the offset value.
myPicture.Offset = New System.Drawing.PointF(4.5F, 2.0F)
|