tags:

views:

740

answers:

2

Hi, i just wanted to know how can i convert text and rich text fields in a document uploaded in a database to html fields.

A: 

I don't think its possible to really do this in lotusscript. But in a Java agent, you can make an http request to the Domino server, which basically forces the server to do its rendering work. Then, you can capture the resulting html and store this back into the same document, or a different one, etc.

If you only want particular text/rich text fields in the rendering, just set up a special form for the conversion with the exact layout and fields desired. Then, create a view with all documents, and add a form formula to ensure that this new form is used. Then, you can reference that view in the URL you create to render each document.

The code in your Java agent would be something like this:

// get the URL that will open that document
// doc is current document to convert
String docid = doc.getUniversalID();
String notesURL = "/" + DB_PATH + "/" + YOUR_VIEW + "/" + docid + "?OpenDocument";
URL docURL =new URL(notesURL);
streamIn = docURL.openStream();
str = new InputStreamReader(streamIn);
binIn = new BufferedReader (str); 

String lineNext; 
StringBuffer sb = new StringBuffer();
while ( (lineNext = binIn.readLine( )) != null ) { 
    sb.append(line);
} 
String sHTML = sb.toString();
// then store sHTML somewhere
Ed Schembor
A: 

Knew I'd seen it somewhere:

nsftools.com to the rescue

The core of the trick is to save the content as MIMEParts.

The sample code is 5 years old and was designed for R6 but Notes has pretty good backwards compatibility. I've also had personal experience that going the other way from MIME to RichText is straightforward so you should be ok.

For the normal text fields you may want to copy their content to a rich text field or use the feature from the above link that allows you to render entire documents.

LRE