This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal


Jul 30, 2015, 7:19 AM
2 Posts

image field Photo - Personal Address Book

  • Category: Domino Designer
  • Platform: All Platforms
  • Release: 9.0.1
  • Role: Developer
  • Tags: Java,rich text,contactphoto
  • Replies: 3

Hello,

I'm trying to load a image to field "photo" from database "Personal Address Book" with a Java program.

I see this field is a Rich Text Lite configurated to show thumbnails.

I don't get save a image and show it.

First,I load a file image and convert it to thumbnail. After I use the command:

  img.embedObject(EmbeddedObject.EMBED_ATTACHMENT, null, path2,  "ContactPhoto");

But I don't see the photo but is created a internal field called "$File" with a file name generated randomly.

I verify that I load manually a photo in this field. It creates a internal field called "$file" with a name file "contactphoto".

I think if this command saved the file with name "ContactPhoto" I would work.

Please, could someone help me? I 'm desperate...


thank you

 

Jul 30, 2015, 2:13 PM
13 Posts
Please don't cross-post

You posted this in every single forum:
http://www-10.lotus.com/ldd/nd6forum.nsf/0/02f0a933eca818da85257e920027e2da
http://www-10.lotus.com/ldd/nd8forum.nsf/0/3f660c4fc03473f885257e9200284a59
http://www-10.lotus.com/ldd/nd85forum.nsf/0/711f97499a4a0cec85257e9200282cb4
http://www-10.lotus.com/ldd/ndseforum.nsf/xpTopicThread.xsp?documentId=AA623DA9006E400385257E9200283FA9

Post only in the forum for the version of Notes/Domino that you are using (9.0 in your case, based on your post in the 8.5 forum).

The people who answer questions in the forums do it for free, in their spare time. If you cross-post and waste/or our time (for example by not bothering to post enough code and/or information), we will not bother helping you.

It does not matter how desperate you are, if it is that important your company could hire a developer/consultat who know and understand Notes.

 

Now to the problem:

1) Have you tried using an extension for the image?

2) How do you "load a file image and convert it to thumbnail"? Is that an external process?

3) Is the "random file name" that random file name Notes automatically generate for duplicate attachments with the same name as an existing file? I think it is a 8 character file name...

4) How is the object img declared and initialized?

5) Can you post more code?

6) Are you sure that RichText Lite fields actually support attaching files like that? This is what the online help says:
http://www-12.lotus.com/ldd/doc/domino_notes/Rnext/help6_designer.nsf/0/f3862b15493727e385256c54004b6df7

7) Is the field-in-question set to accept attachments? I believe that you in one case is embedding the image (inserting it) vs attaching the file. Those are two different things.

 

 

Aug 4, 2015, 9:28 AM
2 Posts
image field Photo - Personal Address Book

Hello,

I apologize for posting in various forum.

 

1) Have you tried using an extension for the image?

I tried to use extension "jpg". And I test with other type images as "png" and "gif"


2) How do you "load a file image and convert it to thumbnail"? Is that an external process?

I use a java program to convert file image to thumbnail. I use the code that I found in document  "BP107: Ten Lines Or Less Interesting Things You Can Do In Java With Minimal Code". You can see in "http://es.slideshare.net/panagenda/bp107-ten-lines-or-less-interesting-things-you-can-do-in-java-with-minimal-code"


3) Is the "random file name" that random file name Notes automatically generate for duplicate attachments with the same name as an existing file? I think it is a 8 character file name...

I have tested the file name "photo", "photo.jpg".


4) How is the object img declared and initialized? Yes, it's. 

 

I can see the image files in disk and open them.

5) Can you post more code?

 

I write a short example:

public static byte[] createThumbnail(InputStream in, float size)throws IOException {
        ByteArrayOutputStream baos=null;
        String msg="";
        try {
            if (in==null)
                _log.error("is null");
            BufferedImage bi = ImageIO.read(in);        
        
            
            float scale = Math.min(size/bi.getHeight(), size/bi.getWidth());
            BufferedImage thumb = new BufferedImage(bi.getWidth(),
                bi.getHeight(), bi.getType());
            AffineTransformOp op = new AffineTransformOp
                (AffineTransform.getScaleInstance(scale, scale),
                        AffineTransformOp.TYPE_BICUBIC);
            thumb = op.filter(bi, thumb);
            thumb = thumb.getSubimage(0, 0,(int)(bi.getWidth()*scale), (int)(bi.getHeight()*scale));
             baos = new ByteArrayOutputStream();
            ImageIO.write(thumb, "jpg", baos);
            _log.debug("Convert image to thumb");
            return baos.toByteArray();
        }catch (Exception e) {
            msg="Some error to convert he image to thumb "+e.getMessage() ;
            _log.error(msg,e);
            e.printStackTrace();
        }
        return baos.toByteArray();

    }
    
    public static void ConvertThumbnail(String path,String path2) {
        
        /
          OutputStream targetFile = null;
        try {
            targetFile = new FileOutputStream(path);
            InputStream is = new BufferedInputStream(new FileInputStream(path));
            _log.debug("I read the image file  "+path);
            if (is==null)
                _log.error("is null");
            byte[] thum;
            try {                
                thum = createThumbnail(is, 50);
                _log.debug("Try to convert image to  thumbnail and convert it to file "+path2);
                 OutputStream targetFile2 = new FileOutputStream(path2);
                targetFile2.write(thum);
                targetFile2.close();
            } catch (IOException e) {
                _log.error("Error to convert the thumbnail  "+path2,e);
                e.printStackTrace();
            }
            
        } catch (FileNotFoundException e) {
            _log.error("Error to load the image  "+path,e);
            e.printStackTrace();
        }
                        
    }

 

public static  void FillDocumentPABLibretaPersonal(Session sesion,String path) throws NotesException {
        Document doc=null;
         Database db=sesion.getDatabase("TEST//ACME ", "ejemplos\\miembrospab7.nsf");
         if (db != null) {
             doc = db.createDocument();              
          
             doc.replaceItemValue("form","Person");
             doc.replaceItemValue("type","Person");
             String lastname="Sanchez Romero";
             String firstname="Paco";          
             doc.replaceItemValue("lastname",lastname);
             doc.replaceItemValue("Firstname",firstname);
             doc.replaceItemValue("Fullname",firstname+" "+lastname);
             RichTextItem img = null;                                                
             img = (RichTextItem) doc.getFirstItem("Photo");
                 if (img !=null) {
                     _log.info(".getFirstItem Tiene campo Photo");
                 }else {
                     _log.info(".getFirstItem No tiene campo Photo");
                     if (doc.hasItem("Photo"))
                         _log.info("hasItem Ya tiene campo Photo");
                  else {
                      img = doc.createRichTextItem("Photo");
                      _log.info("hasItem. Creamos el campo Photo");
                  }                           
        
              }
             img.embedObject(EmbeddedObject.EMBED_ATTACHMENT, null, path,  "ContactPhoto");
  
             doc.save();
             _log.info("Document save");;
          }
    
    }
    

String path="c:\\basura\\photos\\ContactPhoto.jpg";
String path2="c:\\basura\\pfotos\\ContactPhoto2.jpg";

I tried this 

img.embedObject(EmbeddedObject.EMBED_OBJECT,"", path,  "ContactPhoto");

 

but it shows

NotesException: Could not create OLE file from C:\Windows\TEMP\notesB7FA22\40101D58.TMP

 

It the field is  only a "Rich Text" I see a image file attach to field. The problem is with "Rich Text lite" field.

 

thank very much

Regards

 

Aug 4, 2015, 2:50 PM
13 Posts
A guess...


What does img look like in the debugger after you initialize it here:

img = (RichTextItem) doc.getFirstItem("Photo");

Since you are doing this in Java, I am not sure what the debugger would show, but in the Domino Designer debugger you would see what data type the object is.

 

You may want to add some type checking on the IMG object, the equivialent of:

If ( rtitem.Type = RICHTEXT ) Then
 

My guess is that Rich Text Lite does not support all the functionality of a regular Rich Text field. So I am not surprised the file is not attached there correctly.

 

 


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal