Content Management and Capture

Content Management and Capture

Come for answers. Stay for best practices. All we’re missing is you.

 View Only
  • 1.  Annotating a Document using Java

    Posted yesterday

    I have a requirement to add annotations programmatically using Java code. I have tried it and can see the annotation applied for the document in the CPE, but when I open the same document in the ICN. I'm unable to view the annotation that was applied to the document. Here is the code.

    ContentElementList docContentList = doc.get_ContentElements();
    Integer elementSequenceNumber = ((ContentElement) docContentList.get(0)).get_ElementSequenceNumber();
       
    Annotation annObject = Factory.Annotation.createInstance(os, "Annotation");
       
    annObject.set_AnnotatedObject(doc);
       
    annObject.set_AnnotatedContentElement(elementSequenceNumber.intValue() );
       
    annObject.set_DescriptiveText("Annotation applied to the document's 1st content element.");
       
    File annotationFile = new File("C:\\annotation.txt");
       
    ContentTransfer ctObject = Factory.ContentTransfer.createInstance();
    ContentElementList annContentList = Factory.ContentTransfer.createList();
    try
    {
       FileInputStream fileIS = new FileInputStream(annotationFile.getAbsolutePath());
       ctObject.setCaptureSource(fileIS);
    }
    catch (Exception e)
    {
       System.out.println(e.getMessage() );
    }


    annContentList.add(ctObject);
    annObject.set_ContentElements(annContentList);

    annObject.save(RefreshMode.REFRESH);


    https://www.ibm.com/docs/en/filenet-p8-platform/5.2.1?topic=annotation-working-objects

    Followed the above URL from IBM, Was I missing something here? 



    -------------------------------------------


  • 2.  RE: Annotating a Document using Java

    Posted 12 hours ago

    Hi Asheesh, your annotation content must contain the GUID of the document and content element number, page number and coordinates among other information like color and such. The viewer uses the annotation to place the anno on the document during viewing.  If the values in XML don't line up to the document object in view no annos will be displayed. Take a look at an ootb annotation.  What I like to do is replace values that need to be populated with a variable prefix. For instance <docid>xdocid</docid>, then I find/replace these locating the "x+tag name" before adding the annotation. Unless you have multi content objects your element sequence number will always be the same FYI. 



    ------------------------------
    Jay Bowen
    www.bowenecmsolutions.com
    Medina, OH
    ------------------------------