Showing IMages in WEB

Hi all

Any one please tell me how to show a image embedded in a Rich Text field over Web.

My requirement is as follows

I have created a document in which there are two text field values and one RT field containing a image.

I heard that the RT field values will not show up in View columns. is it so ?

Now the real issue is i want to show the document in web browser. Iam coding an Agent to get the document from the view and retreive the field values and iam contructing a HTML and saving the HTML type document in another view.

Now when iam previewing the image doesn’t shows up. only the text values are showing up. What could be wrong ?

Iam using doc.Getitemvalue() to retreive field values from the document. Is any other methods are available for RT field.

My coding is as follows

Sub Initialize

On Error Goto errfn

Dim db As NotesDatabase

Dim doc As NotesDocument,webdoc As NotesDocument

Dim vw As NotesView

Dim ss As New NotesSession,style As NotesRichTextStyle

Dim txtval As String,imgval As String,htm As String,item As NotesRichTextItem





Set db=ss.CurrentDatabase

Set vw=db.GetView("vwrtdemo")

Set doc=vw.GetFirstDocument()

Set webdoc=db.CreateDocument

webdoc.form="frmRT_Web"

Set item=webdoc.CreateRichTextItem("fldrt_web")

Set style=ss.CreateRichTextStyle

style.PassThruHTML=True

Call item.AppendStyle(style)	



htm={<h3>This is a sample demo of RT Image functionality.</h3><br/>}

While Not doc Is Nothing

	txtval=doc.GetItemValue("comment")(0)

	imgval=doc.GetItemValue("rt_image")(0)

	Msgbox txtval

	Msgbox imgval

	htm=htm+Cstr(txtval)+{<br/>The corresponding image is : }+Cstr(imgval)+{<br/>}

	Set doc=vw.GetNextDocument(doc)

Wend

htm=htm+{<br/>Thats the end guys..</br/>}

Call item.AppendText(htm)

Call webdoc.Save(False,True)

Msgbox "finished generation"

Exit Sub

errfn:

Msgbox "Error at line : " & Erl & "Error type : " & Error & "Error Number : " & Err,0+16,"Error Occurred"

Exit Sub

End Sub

what else iam missing in the above code…?

Help on this is much appreciated

Thanks & Regards

VJ

Subject: Showing IMages in WEB

I would say that you are retrieving the text value,

doc.GetItemValue(“rt_image”)(0)

hence it’s not clear why would you expect the image to show up.

You sort of think that the LS will guess that you mean to get HTML presentation of the item. In any case easy convertion to HTML is not possible either. And it is hard in general case to figure out the url to the image. In case of native Notes RT it have to be based on calculation of image offsets in field and that is the hard part.

You have about 4-6 possibilities to display an image contained in the document on web (provided you show it from a view and not display that image doc directly; in the latter case you have no problem of course):

  1. use attachments instead of imported images, then you are able to construct the urls from attachment names. The easiest, if you need also “imported” image, you can always import the attachment as an image, so you store it twice – for viewing on Notes and web separately

  2. save your RT items as MIME (use field properties) This will impact the quality of your rendering (it’s not more native Notes RT), but you’ll also be able to construct the urls

  3. use C API to parse rt item content to construct URLs (quite complex, but works with native Notes RT). This works based on calculation of image offsets in field.

  4. provided you store only a single image in each field and nothing more and do not change hidewhen formulea or any paragraph properties (say you have RT-lite field; you can figure out the urls, as image offsets in every field stays the same. This is a bit risky as when upgrading Notes version it may start using different offset (when adding a new image) even if nothing changes otherwise. Also when editing you may cause the offset change, so this is not really reliable for production purposes.

  5. use iframes and show each document containing an image with a form that shows only the image field

  6. use a piece of code that retrieves each document via http, find and use the image url (and save in the document for re-use, say in the view column). After each update of the image field you’ll need to repeat this operation.