PermaLinkQuestion for RichText gurus
posted Thursday 23rd, September 2004
 



I was emailed today with these 2 questions:
I have an application which maintains employee profiles. When an employee fills out their profile, they paste their picture in a RichTextField using either Create-Picture or File-Import. The image therefore is not stored as an attachment or as an embedded object. How then can I get the image name? Also, do you know of a way to convert an image that has been pasted into a RTF into an attachment and store it in another RTF so that I can then reference @AttachmentNames?

Anyone have a suggestion?
Comments :
 
 

1. Posted by Ben Langhinrichs - website09/09/2007 08:42 PM



I feel like Lurch saying "You rang?"

There is no way to get the name of the original photo unless someone chose to store it in a separate field. An unfortunate decision by Lotus years ago is to not save the name of an image file that is imported.

As for getting the image out, you have a couple of options, depending partly on which version of Notes/Domino you have, and partly on whether it was a GIF, JPEG or BMP originally. In ND6.0.2 or above (I kid you not), you can use DXL to extract a bitmap image to Base64 encoding and then convert it to its native format and save it as a file. From ND6.0.0 and on you can do the same with JPEG and GIF. In either Notes 5 or ND6, you can do this more easily with our Midas Rich Text LSX (http://www.GeniiSoft.com/showcase.nsf/MidasLSX) using the ExportGraphic method, but it costs money.




2. Posted by Adam Gadsby09/09/2007 08:42 PM



I use this code to check whether a RT field has a pasted image in it. You might be able to hack this to suit your requirements.

Function hasGraphic( ) As Boolean
' finds out whether the current document (open on screen) contains a graphic in a rich text field.
Dim session As New NotesSession
Dim wksp As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim rti As NotesRichTextItem
Set uidoc = wksp.CurrentDocument
If uidoc.EditMode Then Call uidoc.Refresh(True)
Set doc = uidoc.Document
Dim dxlx As NotesDXLExporter
Set dxlx = session.CreateDXLExporter( )
Dim strOut As String
strOut = dxlx.Export(doc)
hasGraphic = Instr(strOut, "<picture") > 0
End Function




3. Posted by Joe Litton - website09/09/2007 08:42 PM



Ben: ...I was certain Midas could make this easy. The gent who email works for an educational institution, so I'll leave it to him to determine if they can spring a few bucks for a lot of power and time savings with all things rich text.

Adam: Too cool! You have motivated me to finally get off my rump and experiment with DXL this weekend (it seems to be the rage among Domino folks of late, anyway).

Thanks, gents; this community rocks! I hope Dan (the gent with the dilema) is running a current version of Notes.




4. Posted by Dan09/09/2007 08:42 PM



Hey Joe,

Thanks for posting my question on your blog and thanks to all those who responded. Unfortunately because of budget constraints (State Univ), Midas is not an option at this point.

Adam, I'll play around with your idea for a bit. Would it work on an R5 server too?

In the meantime, I have a hack that I might implement based on this LDD article: http://www-10.lotus.com/ldd/today.nsf/Lookup/Attach_import

Best of both worlds. Have them attach their image to the document instead of importing or pasting it and then run code to import that image into another RTF for display.

Dan




5. Posted by Mac Guidera - website09/09/2007 08:42 PM



@Adam & Joe,
If you had DXLPeek installed you could write an agent that could retrieve the Document DXL for you.

Behind the scenes, there's an agent hard at work called DXLService. You can use it to request the same DXL that DXLPeek provides. So, if you know the UNID of a doc in a DB, then you can get it's DXL. Or the DXL of the "About" doc, about the DXL of the Database script, or even an Image Resource.

Then instead of string parsing you can use DOM or SAX to pull out whatever you need.

</plug>
--Mac




6. Posted by Chris King - website09/09/2007 08:42 PM



Dan, I'd agree that you would want to change the way that they are attaching the graphic. Ultimately, you would want to avoid the whole messy business and make them attach the picture as an attachment. Then you can display that attachment in a variety of ways. My favorite is pass-thru HTML using @Attachment to create the img tag especially now that the client understands it too.

You may also be left with a one-time task of converting all of the pictures to attachments. If it's a small number, you can always use the trick of displaying the page in a web browser (Domino is kind enough to convert it to gif or jpg for you). Then, you can right-click, save as, and re-attach. You're golden. This is a good trick for one-offs.




7. Posted by morshed09/09/2007 08:42 PM



Can anyone tell me dxl exporter exports image of the rich text in which format (in the xml) file? And How i can use the content of <picture> tag to show the image in a html page.