Extracting images using Java

Hi Gurus,
Need your help.
We are in the process of converting Lotus Notes articles into Other Tool. We are successful in extracting all tags/content except images embedded/part of Rich Text field.
We are on Lotus Notes 6.5 and using Java Program to extract these images. Following code we are using but no luck:

public void downloadAttachment(Document doc, Item item, String folderlocation  )
    {
        try
        {
        if (item.getType()==Item.RICHTEXT)
            {
              RichTextItem rtItem = (RichTextItem) doc.getFirstItem(item.getName());
 
              Vector v = rtItem.getEmbeddedObjects();
 
              Enumeration e = v.elements();
                while (e.hasMoreElements()) {
                    EmbeddedObject eo = (EmbeddedObject)e.nextElement();
 
 
                      System.out.println("richtextItem getFormattedText = " + richtextItem.getFormattedText(true, 100000000, 0));
 
 
                    System.out.println(eo.getName() + " Object " + eo.getObject()+ " Type " + eo.getType() + " FileSize " + eo.getFileSize());
 
                    if (eo.getFileSize() > 0)
                    {
                        eo.extractFile(folderlocation+eo.getName());
                    }
 
                }
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
 
We are using richtextItem.getFormattedText method to get the formatted text but unfortunately formatted text function is returning as Plan text in formatted order, we are unable to download the images attached to the field.
batharun2Asked:
Who is Participating?
 
Sjef BosmanGroupware ConsultantCommented:
It's not relevant if you use email or not.

Did you try with the RichTextNavigator class?

Otherwise, what is your current code?

There is a 3rd way: export the document as DXL/XML, and recreate the images from the XML that Notes produced. You need the DXLExporter class. It was also new in R6.5, just like MIME. Bugs to be expected...
0
 
Sjef BosmanGroupware ConsultantCommented:
a/ getFormattedText does what the name says: it gets the text, and only the text, as a formatted string.
b/ you should have upgraded to Notes R9... (sorry, but it's such a waste to move away).
c/ you need to investigate the RichTextNavigator class.

I cannot remember whether that class already existed in R6.5. Ah, I just found it in the Help database, it does. Another issue might be that it used to have some bugs in it, as far as I can remember, but what can you expect of a release that went out of support 1785 days ago (http://www.wissel.net/). Luckily, Notes R9 is still compatible with R6.5, something that probably cannot be said of Other Tool 34.1...

Maybe this ( http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/Lotus_IBM/Q_28140436.html ) will lead you into the right direction.
0
 
batharun2Author Commented:
We are using Lotus Notes 6.5 and trying to download the inline images, when we tried to read the embedded object from richtext field we are not being able to get the inline images.

we tried to get the the inline images from following fuctions:
public void downloadAttachment(Document doc, Item item, String folderlocation  )
    {
        try
        {
        if (item.getType()==Item.RICHTEXT)
            {
              RichTextItem rtItem = (RichTextItem) doc.getFirstItem(item.getName());
                System.out.println(rtItem.getEmbeddedObject("29FA.gif"));
               
              Vector v = rtItem.getEmbeddedObjects();

              Enumeration e = v.elements();
                while (e.hasMoreElements()) {
                    EmbeddedObject eo = (EmbeddedObject)e.nextElement();
                   
                   
                    String type = null;
                    switch (eo.getType()) {
                        case EmbeddedObject.EMBED_ATTACHMENT :
                          type = "file attachment"; break;
                        case EmbeddedObject.EMBED_OBJECT :
                          type = "embedded object"; break;
                        case EmbeddedObject.EMBED_OBJECTLINK :
                          type = "object link";
                    }
                   
                    System.out.println("\t\tType: " + type);
                   
                    System.out.println(eo.getName() + " Object " + eo.getObject()+ " Type " + eo.getType() + " FileSize " + eo.getFileSize());
                   
                   
                    if (eo.getFileSize() > 0)
                    {
                        //eo.extractFile(folderlocation+eo.getName());
                    }

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

when we tried following fuction

Document doc = entry.getDocument();
                       
                            Vector items = doc.getItems();
                            for (int j=0; j<items.size(); j++) {
                                Item item = (Item)items.elementAt(j);
                                if (item.getType()==Item.RICHTEXT){
                                        RichTextItem richtextItem = (RichTextItem) doc.getFirstItem(item.getName());
                                        System.out.println(richtextItem.getMIMEEntity());
            }
                            }
we are getitng MimeEntry as null

Thanks
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
Sjef BosmanGroupware ConsultantCommented:
You can only get a MIME entity from an item of type MIME_PART. A Rich Text item doesn't contain a MIME entity.

Example from the Help database:
http://www-01.ibm.com/support/knowledgecenter/SSVRGU_9.0.1/com.ibm.designer.domino.main.doc/H_EXAMPLES_MIMEENTITY_CLASS_EX_JAVA.html
0
 
batharun2Author Commented:
Can we donload the inline image from MIME Entity ?
0
 
Sjef BosmanGroupware ConsultantCommented:
Maybe, I'm not sure.

The page below contains some JavaScript for XPages that can get an image from a MIME entity. Up to you to convert it to Java...

http://www-10.lotus.com/ldd/ddwiki.nsf/dx/NotesMIMEEntity_sample_JavaScript_code_for_XPages
See getContentAsBytes
0
 
batharun2Author Commented:
we are unable to convert the Rich Text Field to Mime Field in Lotus notes 6.5 document (we Are not using the Email fuctionality of Lotus Notes).

Can you please suggest how we can download the inline Images from RichText Field, so far we are unable to get inline images
inline-images.PNG
0
 
batharun2Author Commented:
Can you please provide the sample code to convert image thru Base 64 decoding Notes XML file ?
0
 
batharun2Author Commented:
Can you please help to provid some sample code from where I can download The inline image from Rich Text Field ?
0
 
Sjef BosmanGroupware ConsultantCommented:
No, I cannot, sorry, for I cannot find any on the internet. I already provided 3 different ways to get the inline image, and I regret to say that I do not have the time to follow this up much deeper. I'm just an Expert, we Experts are volunteers, and I only can give you some clues where to look, which usually helps out many a qualified Notes programmer here at EE.

Suggested:
- check the RichTextNavigator again
- otherwise, try to export the document to a file using the Java DXLExporter class, then fetch the images from the text
- or use MIME (but I have no experience with it)

Maybe useful: http://www.openntf.org/projects/codebin/codebin.nsf/0/2A8425FA461E0CE786256F8C0070AAE9

Good luck! Maybe there's some other Expert who can help you, but there are not many Notes Experts left out here...
0
 
Ramanjaneyulu vaddiCommented:
Hi,

Our requirement is to extract LotusDB  document and store it as MS Word document using java. i have used below method to extract content of document.
RichTextItem content = (RichTextItem) document
                                                            .getFirstItem("Body");

But, I could not get the style of the text(ex:bold/italic text,bullet points etc) , everything I have retrieved as plain text.Could you please help me to retrieve whole text same as from LotusDB document.
0
 
Ramanjaneyulu vaddiCommented:
sure Bosman.Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.