| Sub Initialize |
| Dim s As New NotesSession |
| Dim db As NotesDatabase |
| Dim doc As NotesDocument |
| Dim inputStream As NotesStream |
| Dim outputStream As NotesStream |
| Dim dxlexporter As NotesDXLExporter |
| Dim docNode As NotesDOMDocumentNode |
| Dim nodeList As NotesDOMNodeList |
| Dim node As NotesDOMNode |
| Dim parnode As NotesDOMNode |
| Dim textnode As NotesDOMNode |
| Dim pictureNode As NotesDOMElementNode |
| Dim gifNode As NotesDOMNode |
| |
| Set db = s.CurrentDatabase |
| Set doc = db.CreateDocument |
| |
| doc.Form = "Test" |
| |
| Set rtitem = doc.CreateRichTextItem("Body") |
| Call doc.save(True,False) |
| |
| Set inputStream = s.CreateStream |
| Set outputStream = s.CreateStream |
| Set dxlexporter = s.CreateDXLExporter(doc,inputStream) |
| Call dxlexporter.process() |
| |
| Set domParser=s.CreateDOMParser(inputStream, outputStream) |
| domParser.Process |
| |
| 'get the document node |
| Set docNode = domParser.Document |
| ' process here |
| |
| Set nodeList = docnode.GetElementsByTagName("richtext") |
| Set node = nodelist.GetItem(1) |
| |
| Set parnode = docNode.CreateElementNode("par") |
| Call node.AppendChild(parnode) |
| |
| Set pictureNode = docNode.CreateElementNode("picture") |
| Call parnode.AppendChild(pictureNode) |
| |
| Dim heightAttr As NotesDOMAttributeNode |
| Dim widthAttr As NotesDOMAttributeNode |
| |
| |
| Set gifnode = docNode.CreateElementNode("gif") |
| Call pictureNode.AppendChild(gifnode) |
| |
| Dim picture As String |
| Dim fin As Integer |
| Dim finOpen As Integer |
| Dim worktext As String, leftover As String |
| |
| fin = Freefile |
| |
| picture="" |
| Open "c:\test.gif" For Input As fin |
| |
| '** start getting data from the input file, encoding it, and sending it |
| '** to the output file |
| Const CHUNKSIZE = 15000 |
| datain = GetFileChunk(fin, CHUNKSIZE) |
| Do While (Len(datain) > 0) |
| '** encode in groups of 57 characters, which will give us output |
| '** in lines of 76 characters (fairly standard) |
| leftover = leftover & datain |
| While (Len(leftover) > 57) |
| worktext = Left$(leftover, 57) |
| leftover = Mid$(leftover, 58) |
| dataout = EncodeBase64(worktext) |
| picture=picture+dataout |
| Wend |
| datain = GetFileChunk(fin, CHUNKSIZE) |
| Loop |
| |
| '** encode anything we had left, and close the files |
| If (Len(leftover) > 0) Then |
| picture=picture+EncodeBase64(leftover) |
| End If |
| |
| Close #fin |
| |
| Set textNode = docNode.CreateTextNode(picture) |
| Call gifnode.AppendChild(textNode) |
| |
| Call domparser.serialize() |
| |
| Print outputstream.ReadText |
| |
| Dim importer As NotesDXLImporter |
| Set importer = s.CreateDXLImporter ( outputstream , db ) |
| importer.DocumentImportOption = DXLIMPORTOPTION_REPLACE_ELSE_IGNORE |
| importer.ExitOnFirstFatalError = False |
| Call importer.Process |
| |
| End Sub |