Programmer's Guide:
Using Rich Text
Objects that contain rich text information - such as poll questions,
comment bodies, and page descriptions - implement the IERURichText
interface. In the eRoom user interface, text entered into rich-text fields,
such as the folder-description field in the Create dialog, is maintained
internally as HTML.
Converting to and from plain text
The rich text is accessible through a pair of properties in the IERURichText
interface: Text and Html.
Internally, the text is always maintained as HTML. Getting the Text property
returns a string with the HTML tags stripped out. Setting the Text property
interprets the passed-in string as plain text - any HTML tags in the string
will be escaped, so that they appear as plain text in the UI. Getting
or setting the Html property returns or stores a string in HTML format.
Adding, removing and reordering images in rich text
You can add, remove or reorder images in rich text by setting the Html
property of IERURichText.
To add an image to rich text, the "src" attribute of the IMG
tag must have a file path as a value. For example:
<p><img
src="C:\Program Files\MSOffice\Templates\Access\100.jpg"></p>
When the updated rich text is uploaded to the server, any local image
files it references are also uploaded to the server.
To remove an image in rich text, simply remove the "img" tag
from the HTML. To reorder the images in the rich text, simply modify the
"img" tags in the HTML to reflect the order in which you want
the images to appear.
The following code snippet shows how to accomplish image-related tasks
using Visual Basic:
' Get a folder
item
Set Item = Room.GetItem("577_1f")
' Get folder page description
Set Richtext = Item.FolderPage.Description
' Add an image in the description
Richtext.Html =
"<p><img src=""C:\Program Files\MSOffice\Templates\Access\100.jpg""></p>"
Dim Html As String
Html = Richtext.Html
'An "img" tag would be of the form
' "file://the local file path of the image file on the server".
' For example:
' <p><img src="file://C:\Program Files\eRoom Server\ServerData\_Graphics
'\MyFacility\577_1f\DescriptionGraphic0001v1.jpg"></p>
' For simplicity, the following code assumes the server manager is used.
' To add another image, just append the new html
Richtext.Html = Richtext.Html + _
"<p><img src=""C:\Program Files\MSOffice\Templates\Access\Tiles.jpg""></p>"
' If you got the html now, you would get
' <p><img src="file://C:\Program Files\eRoom Server\ServerData\_Graphics
'\MyFacility\577_1f\DescriptionGraphic0001v1.jpg"></p>
' <p><img src="file://C:\Program Files\eRoom Server\ServerData\_Graphics
'\MyFacility\577_1f\DescriptionGraphic0002v1.jpg"></p>
' Reorder the two images
Richtext.Html = _
"<p><img src="" file://C:\Program Files\eRoom Server\ServerData\_Graphics"
_
& "\MyFacility\577_1f\DescriptionGraphic0002v1.jpg""></p>"
_
& "<p><img src="" file://C:\Program Files\eRoom
Server\ServerData\_Graphics" _
& "\MyFacility\577_1f\DescriptionGraphic0001v1.jpg"">&ly;/p>"
' Delete one of the images
Richtext.Html = _
"<p><img src="" file://C:\Program Files\eRoom Server\ServerData\_Graphics"
_
& "\MyFacility\577_1f\DescriptionGraphic0002v1.jpg""></p>"
|