Тема: Использование Java библиотек в Lotusscript
Кнопочка выгражает в XML файл (C:\text\supertest.xml) вложения в формате PDF в Base64 кодировке.
В опциях подключаем
Use "Base64Java"
Use "libBase64"
Sub Click(Source As Button)
Dim session As New NotesSession
Dim uiworkspace As New NotesUIWorkspace
Dim histold As String
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc =uiworkspace.CurrentDocument
Set doc =uidoc.Document
datapatch$ = {C:\out\}
Dim rtitem As NotesRichTextItem
Set rtitem = doc.GetFirstItem( "ПРИЛОЖЕНИЯ_" )
Set strm = session.CreateStream() ' XML-ка
Call strm.Open("C:\text\supertest.xml", "UTF-8")
xml = {<html xmlns='http://_.w3.org/1999/xhtml' encoding='UTF-8'>}+ Chr(13)
xml = xml + {<head>} + Chr(13)
xml = xml + {</head>} + Chr(13)
xml = xml + {<body>} + Chr(13)
Dim inStream As NotesStream
Set inStream=session.Createstream() ' сохряненный файл на винте
Dim currentLog As New NotesLog( "Script log" )
Call currentLog.OpenFileLog( "d:\log.txt" )
Dim mySession As JavaSession
Dim myClass As JavaClass
Dim myMethod As JavaMethod
Dim jBase64 As JavaObject
Set mySession = New JavaSession()
Set myClass = mySession.GetClass("Base64Java")
Set myMethod = myClass.GetMethod("encodeFile","(Ljava/lang/String;)V")
Set jBase64 = myClass.CreateObject()
'Call getMethodSignatures (myClass,currentLog)
Forall obj In rtitem.EmbeddedObjects
If ( obj.Type = EMBED_ATTACHMENT ) Then
Call obj.ExtractFile( datapatch$ & obj.Source )
oname$ = obj.Source
Argument = datapatch$ & oname$
xxx = myMethod.Invoke(jBase64, Argument)
Call inStream.Open(datapatch$ & oname$) ' в поток inStream файл
plainText$ = inStream.ReadText()
If Strright(oname$, ".") = "pdf" Then
xml = xml + {<Application>} + {<a href="data:application/pdf;base64,} + plainText$ +{">} + oname$ + {</a>} + {</Application><br />} + Chr(13)
End If
Call inStream.Close
Kill datapatch$ & oname$ ' стереть файл
End If
End Forall
xml = xml + {</body>}
xml = xml + {</html>}
Call strm.WriteText(xml)
Call strm.Close
End Sub