How to create a pragraph in a RichTextItem?

I am sure this is a really easy thing to do. I just miss one thing and I am not able to figure out what. I am reading myself through the forum of R6 and R5 and the NotesHelp. But I just do not get it.

I have an agent which collects text from documents and puts them in a NotesRichTextItem. I am able to apply RichTextStyles. The first line I add to the RichTextItem is just a kind of Timestamp. Then the next AppendText is the text which I tooke from another document. This text is mostly multiline text.

What I would like to do is to inset this text a little bit so it is easier to read. But I am not able.

The code looks like this now

Dim rtpStyle As NotesRichTextParagraphStyle

Set rtpStyle = session.CreateRichTextParagraphStyle

rtpStyle.LeftMargin = RULER_ONE_CENTIMETER

rtpStyle.RightMargin = RULER_ONE_CENTIMETER

rtpStyle.FirstLineLeftMargin = RULER_ONE_CENTIMETER

rtItem.AppendStyle(tmstStyle)

rtItem.AppendText(tmst)

rtItem.AddNewline(1)

rtItem.AppendStyle(textStyle)

rtItem.AppendParagraphStyle(rtpStyle)

rtItem.AppendText(text)

rtItem.AddNewline(1)

What is wrong here? Could anybody help me please? I am really stuck now.

Thanks in advance

Subject: How to create a pragraph in a RichTextItem?

Hi,

You have to higher the values you use for left and right margins, as RULER_ONE_CENTIMETER is the base unit.

You can try :

rtpStyle.LeftMargin = RULER_ONE_CENTIMETER*3

rtpStyle.RightMargin = RULER_ONE_CENTIMETER*15

rtpStyle.FirstLineLeftMargin = RULER_ONE_CENTIMETER*4

Eric.

Subject: RE: How to create a pragraph in a RichTextItem?

I tried this

Dim rtpStyle As NotesRichTextParagraphStyle

Set rtpStyle = session.CreateRichTextParagraphStyle

rtpStyle.LeftMargin = RULER_ONE_CENTIMETER * 2

rtpStyle.FirstLineLeftMargin = RULER_ONE_CENTIMETER * 1

rtpStyle.RightMargin = RULER_ONE_CENTIMETER * 5

data.AddNewline(1)

data.AppendText(“TEST”)

data.AddNewline(1)

Call data.AppendParagraphStyle(rtpStyle)

data.AppendText(“1 line”)

data.AddNewline(1)

data.AppendText(“2 line”)

data.AddNewline(1)

data.AppendText(“3 line”)

data.AddNewline(1)

data.AppendText(“4 line”)

The output is like this

TEST

1 line

2 line

3 line

4 line

All is aligned on left side, even, line 2, 3 and 4 should be intended compared to line 1.

I do not understand it anymore. I keep trying and trying. Now I am stuck.

Subject: RE: How to create a pragraph in a RichTextItem?

Hi!

I do not understand why it does not work with your code. You may have some other style defined before the rich text?

I tested with a simple form called “Test”, with has a rich text field called “Body”, and using this agent code :

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim rtitem As NotesRichTextItem

Dim object As NotesEmbeddedObject

Set db = session.CurrentDatabase

Set doc = New NotesDocument( db )

Set rtitem = New NotesRichTextItem( doc, "Body" )

doc.Form = "Test"



Dim text As String

text = |1111111

2222222

3333333

4444444

bla bla bla|

Dim rtpStyle As NotesRichTextParagraphStyle

Set rtpStyle = session.CreateRichTextParagraphStyle



rtpStyle.LeftMargin = RULER_ONE_CENTIMETER * 3

rtpStyle.RightMargin = RULER_ONE_CENTIMETER * 15

rtpStyle.FirstLineLeftMargin = RULER_ONE_CENTIMETER * 3



Call rtItem.AppendText("a timestamp here")

Call rtItem.AddNewline(1)

Call rtItem.AppendParagraphStyle(rtpStyle)

Call rtItem.AppendText(text)

Call rtItem.AddNewline(1)	





Call doc.Save( True, True )

End Sub

Subject: RE: How to create a pragraph in a RichTextItem?

I got it.

Put your RTI in table and you will have the same effect. All my RTI are okay as long as I do not have them in table in the form.

Regards,

Subject: RE: How to create a pragraph in a RichTextItem?

I figured out what the problem is. It is the CRLF. When I build a message I do it like this:

msg = “blablabla”

msg = msg + chr(13) + chr(10) + “blublublu”

this is then the text I append to the rich text item.

The result is that the paragraph styles are not applied.

If I do it like this(as you mentioned)

msg = {blablabla

blublublu}

then the parapgraph styles are applied.

Unfortunately I cannot build the message like this. The agent gets the text for the rich text item from several documents. I will need to figure out about the CRLF charachter sequence to use.

Thanks for the help

Subject: RE: How to create a pragraph in a RichTextItem?

CRLF does not necessarily create a new paragraph. AddNewLine() does. A rich text paragraph can contain a formatted string, which may include a carriage rturn/line feed. AddNewLine() creates a new rich text paragraph entity.