ConvertToHTML (RichTextItem - Java)

Call this method to convert a RichTextItem to an HTML string. The form of the HTML created is similar to what is produced by the Domino® web server and sent to the client. Parameters that guide how the conversion is done can be supplied by a Vector of Strings (Java) or an array of strings (LS). After this method is called, the getHTMLReferences (RichTextItem class) method can be called. This call returns a Vector (Java) or array (LS) of HTMLReference objects. Each reference object has a Type property, which may be queried to determine how to interpret the data contained within the reference. The HTMLReference class was created to represent the data contained within an HTML reference.

Defined in

NotesRichTextItem

Syntax

public Strings ConvertToHTML(Vector Options)
		throws NotesException;

Parameters

Parameter Description
Options Vector. A vector which includes the parameters list for converting.

Return Values

Return value Description
Vector Vector. The strings of HTML converted from the RTF field content.

Possible Exceptions

Possible exceptions Description
HTML conversion error (4835) The operation failed to convert RTF content to HTML.

Language cross-reference

Converttohtml in LotusScript® NotesRichTextItem class

ConvertToHTML in JavaScript NotesRichTextItem class

Example

This example shows how to use this method to convert a RichTextItem to an HTML string:

import java.util.Date;
import java.util.Vector;

import lotus.domino.*;

public class JavaAgent extends AgentBase {

    public void NotesMain() {

      try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext(); 
          
          Database db = session.getCurrentDatabase();
          DocumentCollection col = db.getAllDocuments();
          Document doc = col.getFirstDocument();
          RichTextItem rt = (RichTextItem) doc.getFirstItem("RTF");
          
          String ret = "Convert RTF to HTML on"+(new Date()).toString()+"\r\n";
          ret = ret +  rt.ConvertToHTML(null);
          
          Vector refs = rt.getHTMLReferences();
          if(!refs.isEmpty()){
        	  for(int i =0; i< refs.capacity();i++){
        		  HTMLReference ref = (HTMLReference) refs.get(i);
        		  ret = ret + "\r\n";
        		  ret = ret + "Refrence Number:" + i +"\r\n";
        		  ret = ret + "Type ID:"+ ref.getType() +"\r\n";
        		  ret = ret + "Command ID:"+ ref.getCommandID() +"\r\n";
        		  ret = ret + "URL:"+ ref.getURL() + "\r\n";
        		  ret = ret + "FileName:"+ ref.getFileName() + "\r\n";
        		  ref.extractFile("C:\\kkk.gif",true);
        	  }
         } 
         System.out.print(ret);

      } catch(Exception e) {
          e.printStackTrace();
       }
   }
}