Subject: AddPageBreak - an example
I may be able to provide an example of where AddPageBreak is not working for me. I am using Notes 7.0.1. The code’s objective is to take the Rich Text Body fields from several documents and combine them into one Rich Text field in another document. This works find using AppendRTItem(). However, if I also try to insert a page break in between each appended chunk of text, the AddPageBreak() call seems to be ignored. The source document’s rich text content (called ‘attachments’) are mostly simple text with basic formatting.
Here’s the code (simplified from my actual):
Sub AppendAttachments( s as NotesSession, thisDb As NotesDatabase )
Dim p_d_letter As NotesDocument ’ new doc
Dim p_attachments(1 To 2) As String
Set thisDb = s.CurrentDatabase
p_attachments(1) = “sampledoc1”
p_attachments(2) = “sampledoc2”
Set p_d_letter = New NotesDocument( thisDb )
Call p_d_letter.ReplaceItemValue(“Form”, “ResponseLetter”)
Set l_v_attachments = thisDb.GetView(“attachments”)
Set l_rt_body = p_d_letter.CreateRichTextItem( “AttachmentsBody” )
Forall a In p_attachments
Set l_d_attachment = l_v_attachments.GetDocumentByKey( a, True )
Set l_rt_attbody = l_d_attachment.GetFirstItem("Body")
Call l_rt_body.AddPageBreak( ) ' ******* this is ignored **********
Call l_rt_body.AppendRTItem( l_rt_attbody )
End Forall
Call p_d_letter.Save(True, False)
End Sub
The resulting field and document is complete except for the page breaks. I’ve tried several options:
-
Use the parameter to AddPageBreak( rtstyle) to add a style to the subsequent parapgrah, and specify Pagination = PAGINATE_BEFORE.
-
I tried calling AddNewLine(1, True) before AddPageBreak().
-
I tried calling l_rt_body.Update() in a few places. My understanding was that this was only helpful if you’re using the UI classes also, which I am not.
-
I added a page break at the very beginning of each Rich Text field that was being copied in. They showed up in the source doc ok, but not in the destination doc when copied programmatically.
The only thing that worked somewhat was a variation on #4 above. Instead of putting a page break in the beginning of the source content field, I added it in the middle (i.e. text above and below the break). Only then was the page break copied into the destination field.
The bottom line is that NotesRichTextItem.AddPageBreak() does not seem to work, or it has an undocumented prerequisite that I’m not meeting. Any help would be greatly appreciated.