Hi,
loading rtf or htm and writing rtf or htm
means converting between each other
easy going with the function JTextPane.getEditorKitForContentType
|
Jabaco Source
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
Public Sub RichTextBox_SaveFileHTM(RTB As RichTextBox, aFileName As String)
RichTextBox_SaveFile(RTB, aFileName, "text/html")
End Sub
Public Sub RichTextBox_SaveFile(RTB As RichTextBox, aFileName As String)
'default because RichText = rtf
RichTextBox_SaveFile(RTB, aFileName, "text/rtf")
End Sub
Public Sub RichTextBox_SaveFile(RTB As RichTextBox, aFileName As String, contenttype As String)
'contenttype could either be
' "text/plain", or
' "text/html", or
' "text/rtf"
Dim os As OutputStream = New FileOutputStream(aFileName)
Dim pan As JTextPane = RTB.Parent
Dim kit As EditorKit = pan.getEditorKitForContentType(contenttype)
Dim doc As Document = pan.getDocument
Dim wri As Writer = New OutputStreamWriter(os)
kit.write(os, doc, 0, doc.getLength)
os.flush
os.close
End Sub
|
...but I also found Inconpatibilities:
if text is left-, middle- or rightaligned, the JTextpane does show it correctly but the Editorkit is not able to write it correctly, don't know why.
OlimilO