Thursday, September 07, 2006

Export inline Notes pictures to disk as GIF files

Have you tried to export an inline picture from Notes database to hard drive? You can of course select the picture, copy it to clipboard, paste it to Paintbrush and then save the new picture to disk. But what if there are more than thousand pictures to process? The manual procedure would take several hours.
Fortunately you can programmatically export pictures using Notes DXL classes. The code below takes the first picture in a richtext field named PictureRT and saves it to disk as a GIF file.

The code uses a LotusScript library for BASE64 decoding, which you can download from Julian Robichaux's web site:

Example does not use Notes classes for handling XML (NotesDOMParser), it parses the string using it's own logic. In many cases NotesDOMParser processing is to prefer, and I might later create a version which uses NotesDOMParser.

Option Public
Use "base64encdec"

Sub Initialize
Dim session as New NotesSession
Dim db as NotesDatabase
Dim doc as NotesDocument
Dim picdata As String
Dim decstr As String

set db=session.CurrentDatabase
set doc=db.GetDocumentByUNID("1EC1508B08428D4385256E00004B0D3F")

Set exporter = session.CreateDXLExporter
exporter.ConvertNotesBitmapsToGIF = True
out = exporter.Export(pdoc)

find1="<item name='PersonPicture'"
rtstart=Instr(out, find1)
rtstart2=Instr(rtstart, out, findpic1)
rtfinish2=Instr(rtstart2, out, findpic2)
purepic= Mid(out, rtstart2, rtfinish2-rtstart2+Len(findpic2))

finddata1="<gif originalformat="'notesbitmap'">"
picdatastart=Instr(purepic, finddata1)
picdatafinish=Instr(picdatastart, purepic, finddata2)
picdata=Mid(purepic, picdatastart+Len(finddata1), picdatafinish-picdatastart-Len(finddata2))

fout = Freefile
Open "c:\testgif.gif" For Output As fout
Print #fout, decstr
Close #fout
End Sub


Ferdi Verlaan said...

Very nice and helpful! Thanks!

Rickard Carlsson said...

Nice! Thanks for the example.

Anonymous said...

This momentousdecree warcraft leveling came as a great beacon light wow lvl of hope to millions of negroslaves wow power level who had been seared power leveling in the flames of power leveling withering wrath of the lich king power leveling injustice.wrath of the lich king power leveling it came as a WOTLK Power Leveling joyous daybreak to end the long WOTLK Power Leveling night ofcaptivity.WOTLK Power Leveling but one hundred years wlk power leveling later, we must face aoc gold the tragic fact thatthe age of conan power leveling negro is still not free. aoc power leveling one hundred years later,age of conan power leveling the lifeof the negro ffxi gil is still sadly crippled by the final fantasy xi gil manacles ofsegregation guild wars gold and the chains of discrimination. one hundred yearslater, maplestory mesos the negro lives on a lonely island of poverty in themidst of a vast ocean of material clothes one hundred yearslater

Anonymous said...

Can it work with notes R5?

Blog Cepot said...

They’re amazing I especially liked the last one – Berapa Harga Obat Herbal Kutil Kelamin de Nature Id