aspnet-118560-components-rich-text-editor-document-document-model-floating-objects.md
The RichEdit allows the floating objects (pictures and text boxes) to be inserted into a document by users (via specific UI) or programmatically. Floating means that the object is strictly positioned, absolutely or relatively within the document, regardless of the document text flow. A floating object’s anchor (seen in the picture below) specifies the paragraph with which the object is associated and indicates where the floating object is located in relation to the text.
To create a text box anchored to the given document position, use the RichEditCommands.insertFloatingTextBox client command as the following code snippet demonstrates:
myRichEdit.commands.insertFloatingTextBox.execute();
The inserted text box is at the beginning of the first paragraph on the page that contains a floating object’s anchor by default.
There is no an individual dedicated client command to create floating pictures. To insert a floating picture, do the following:
Example:
var settings = {
floatingObjectTextWrapType: ASPx.FloatingObjectTextWrapSide.Both,
floatingObjectTextWrapSide: ASPx.FloatingObjectTextWrapType.Square
};
var imageUrl = "https://demos.devexpress.com/ASPxImageAndDataNavigationDemos/Content/Images/landscapes/07.jpg";
myRichEdit.commands.insertPicture.execute(imageUrl);
myRichEdit.commands.changeFloatingObjectTextWrapping.execute(settings);
You can access floating objects stored in the active sub-document and their information using the SubDocument class’s API in the following notation:
clientRichEdit.document.activeSubDocument.member_name
| Member | Description |
|---|---|
| SubDocument.floatingTextBoxesInfo | Returns information about floating text boxes in the sub-document. |
| SubDocument.getFloatingTextBoxInfo | Returns information specific for floating text boxes about the sub-document. |
| Member | Description |
|---|---|
| SubDocument.floatingPicturesInfo | Returns information about floating pictures in the sub-document. |
The following client commands are available for manipulating floating objects programmatically. Call the commands in the notation given below:
clientRichEditName.commands.commandName.execute(parameter_if_any)
| Command | Description |
|---|---|
| RichEditCommands.changeFloatingObjectTextWrapping | Gets a command to modify a floating object’s text wrapping settings. |
| Command | Description |
|---|---|
| RichEditCommands.changeFloatingObjectAbsolutePosition | Gets a command to change a floating object’s absolute position. |
| RichEditCommands.changeFloatingObjectAlignmentPosition | Gets a command to modify a floating object’s alignment position. |
| RichEditCommands.changeFloatingObjectRelativePosition | Gets a command to modify a floating object’s relative position. |
| Command | Description |
|---|---|
| RichEditCommands.changeFloatingObjectAbsoluteSize | Gets a command to change a floating object’s absolute size. |
| RichEditCommands.changeFloatingObjectRotation | Gets a command to rotate a floating object. |
| RichEditCommands.changeFloatingObjectLockAnchor | Gets a command to lock a floating object’s anchor. |
| RichEditCommands.changeFloatingObjectLockAspectRatio | Gets a command to lock a floating object’s aspect ratio. |
| Command | Description |
|---|---|
| RichEditCommands.changeFloatingObjectOutlineColor | Gets a command to modify a floating object’s outline color. |
| RichEditCommands.changeFloatingObjectOutlineWidth | Gets a command to modify a floating object’s outline width. |
| RichEditCommands.changeFloatingObjectFillColor | Gets a command to modify a floating object’s background fill color. |
| Command | Description |
|---|---|
| RichEditCommands.changeTextBoxContentMargins | Gets a command to modify a text box’s content margins. |
| RichEditCommands.changeTextBoxRelativeSize | Gets a command to modify a text box’s relative size settings. |
| RichEditCommands.changeTextBoxResizeShapeToFitText | Gets a command to resize the shape to fit the text in the text box. |
| Command | Description |
|---|---|
| RichEditCommands.openLayoutOptionsDialog | Gets a command to invoke the Layout dialog window to customize the settings of a floating object. |
Users are allowed to freely position, scale and rotate all floating objects when inserting pictures or text boxes into a document. They can also modify object characteristics using context menu items, a specific ribbon context tab, or activate the built-in Layout dialog through the context menu.
A user can insert a text box object using the Text Box ribbon button located in the ribbon’s Insert tab, in the Text group. A selected floating text box’s contents can be formatted using the Home ribbon tab.
When a floating object is selected, the Format context tab is available in the ribbon. This tab allows users to position the floating object within the document and set the shape’s fill or border color.
Users can rotate and resize a floating object using specially designed handles as shown in the following image. When a floating object rotates, its content is also rotated.
Users can also modify object characteristics using context menu items, or use the built-in Layout dialog invoked through the context menu to set more advanced options.
See Also