I’m copying a Rich Text field from one document to another for printing purposes, by:
Set itemholder = doc.GetFirstItem( "PTM_Text" )
Call docb.CopyItem( itemholder, "PTM_Text" )
itemholder is defined as NotesRichTextItem. docb is the new document.
The font is changing from Garamond 12 to Default Sans 8. How do I retain the original font ?
Thanks, Tom
Subject: CopyItem changing Font & Size of Rich Text Field
Some thoughts that spring to mind …
In the original document, is the text explicitly set to Garamond, or is it set to one of the “Default…” fonts ?
If so, the new document should also have the Default setting which may display differently based on the user’s settings for the default fonts.
Presumably the Garamond font is available on the machine where the new document is being opened ?
What is the Field’s font setting on the Fields for PTM_Text on the form(s) involved ?
If all else fails, you may want to use something like NotesPeek to look inside of the RTF to see how it’s constructed for the original and destination documents. It will show you each specific CD record in the RTF’s. Useful if you need a very low-level understand of the contents.
Subject: RE: CopyItem changing Font & Size of Rich Text Field
Wow, was that a brain cramp… the original field is Default Sans Serif 8, so that’s why it transferred that way and ignored the new form field setting… I knew that, but had a cramp…
Thanks. for the slap on the head…
Is there a way of setting the Font to Garamond 12 after the CopyItem ? In the Help, it just mentions a few fonts by name…
Subject: RE: CopyItem changing Font & Size of Rich Text Field
Look at GetNotesFont to set a NotesFont value other than the four presets.
Subject: RE: CopyItem changing Font & Size of Rich Text Field
Use the NotesRichTextRange object, and a create a NotesRichTextStyle to reset it’s contents.
Here’s the example from the Help which changes the font size. Changing the Font would be similar.
Sub Initialize
Set session = New NotesSession
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
If dc.Count = 0 Then
Messagebox “No document selected”, “No doc”
Exit Sub
End If
Set doc = dc.GetFirstDocument
Set body = doc.GetFirstItem(“Body”)
Set rtrange = body.CreateRange
Set rtstyle = session.CreateRichTextStyle
fontSizeString$ = Inputbox$(“Size 8 - 24”, “Font size”)
If Not Isnumeric(fontSizeString$) Then
Messagebox “Size must be an integer 8 - 24”, _
“Not numeric”
Exit Sub
End If
fontSize% = Cint(fontSizeString$)
If fontSize% < 8 Then fontSize% = 8
If fontSize% > 24 Then fontSize% = 24
rtstyle.FontSize = fontSize%
Call rtrange.SetStyle(rtstyle)
Call doc.Save(True, True)
End Sub
Subject: CopyItem changing Font & Size of Rich Text Field
When you use a non-standard font, the font information is stored in a $Fonts field on the document for reference. Since the $Fonts field does not appear on docB, Notes is forced to make a best-guess substitution (which may or may not work well).