Question

I'm trying to add some pictures in a Notes document but not an attachment picture, just an "import" picture.

I'm trying to do that : it's good with a attachement picture but i don't want that. Could you help me ?

public void modificationDocNotes() throws ExceptionWS {

    String chemin;
    RichTextItem img = null;
    try {           
        monDoc.replaceItemValue("Status", "");
        monDoc.removeItem(docDTO.getNomChampNotes());   
        img = monDoc.createRichTextItem(docDTO.getNomChampNotes());                     


        for(PieceJointeDTO piecejointeDTO : docDTO.getPiecesJointesDTO())
        {
            chemin = docDTO.getRepertoire() + piecejointeDTO.getNomPiece();             

            img.embedObject(EmbeddedObject.EMBED_ATTACHMENT, null, chemin, null);                   


            if (docDTO.getNomChampCommentaire() != null)
            {
                monDoc.replaceItemValue(docDTO.getNomChampCommentaire(), piecejointeDTO.getCommentairePiece());
            }               
        }           
        monDoc.replaceItemValue("Status", "Ferme");
        monDoc.save(true,true);
        img.recycle();
        monDoc.recycle();                       

        System.out.println("modification d'un document Notes");
    } catch (NotesException e) {
        throw new ExceptionWS("ERREUR Notes sur méthode modificationDocNotes() sur Web Service RemonteeBlob RemonteeBlobDAO" , e, logDTO);
    }       
}

bye ant thanks a lot for your help !


i try to do the same thing with html but it doesn't work !

private void buildDocNotes() throws NotesException {
    String chemin;
    RichTextItem img = null;
    img = monDoc.createRichTextItem(docDTO.getNomChampNotes()); 

    StringBuilder builder = new StringBuilder("<html><head>");
    builder.append("MIME-Version: 1.0");        
    builder.append("Content-type: text/html; charset=utf-8");
    builder.append("</head><body>");
    for(PieceJointeDTO piecejointeDTO : docDTO.getPiecesJointesDTO())
    {
        chemin = docDTO.getRepertoire() + piecejointeDTO.getNomPiece();             

        builder.append("<img src='" + piecejointeDTO.getNomPiece() + "'/><br/>");

        img.embedObject(EmbeddedObject.EMBED_ATTACHMENT, null, chemin, null);                   

        if (docDTO.getNomChampCommentaire() != null)
        {
            monDoc.replaceItemValue(docDTO.getNomChampCommentaire(), piecejointeDTO.getCommentairePiece());
        }   
        piecejointeDTO.setResultat("O");
    }           

    builder.append("</body></html>");

    monDoc.appendItemValue(docDTO.getNomChampNotes(), builder.toString());
    monDoc.replaceItemValue("Status", "Ferme");
    monDoc.save(true,true);
    img.recycle();
    monDoc.recycle();
}

Could you help me ? thanks a lot !

Was it helpful?

Solution

Unless you're using the Notes C API, which is a hard from Java, you won't be able to create this directly.

If you always want to use the same image (or one of a limited set), and the image isn't in a table cell or similar, you can manually create reference documents whose rich text field contains just the image you want. Then use the methods of RichTextItem to append the reference document's rich text into the document you're creating at the appropriate point.

If this won't serve for some reason, you can create the DXL description of the document you want, including image, and then import it using a DXLImporter object.

To see an example of the DXL you need to generate, create a sample document manually, and export it (or to do it without writing code, create a Page design element in Domino Designer, and export that using the Tools / DXL Utilities / Viewer menu).

You can create the document in memory and fill in rich text with a placeholder where you want the image. Without saving the document, export it using DXLExporter, then use an XML parser (or just a string search) to find your placeholder and replace it with the base64-encoded image contents and enclosing elements.

The LotusScript Gold Collection project in openntf.org contains examples that might help you, also, but in LotusScript.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top