Java (Apache POI) : How to retrieve comment/annotation and associated highlighted text from Microsoft Word?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Java (Apache POI) : How to retrieve comment/annotation and associated highlighted text from Microsoft Word?

Ramani Routray
I have a Microsoft word (.docx) file and trying to retrieve the comments and it's associated highlighted text. Can you pls help.

Attaching picture of the sample word document and the java code for extracting the comments. [ A file with a line "My name is John". The word "John" is highlighted with a comment "Noun" ]

I am able to extract the comments (Noun, Adjective). I would like to extract the highlighted text associated with the comment from the word document "Noun" (Noun = John, Adjective = great)


FileInputStream fis = new FileInputStream(new File(msWordFilePath));
    XWPFDocument adoc = new XWPFDocument(fis);
    XWPFWordExtractor xwe = new XWPFWordExtractor(adoc);
    XWPFComment[] comments = adoc.getComments();


    for(int idx=0; idx < comments.length; idx++)
    {
        MSWordAnnotation annot = new MSWordAnnotation();
        annot.setAnnotationName(comments[idx].getId());
        annot.setAnnotationValue(comments[idx].getText());
        aList.add(annot);


    }

regards,
Ramani


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Java (Apache POI) : How to retrieve comment/annotation and associated highlighted text from Microsoft Word?

Javen O'Neal-2
Ramani,

Please see my responses from your previous email on the
[hidden email] mailing list. Make sure you're subscribed to a
mailing list before sending a message to it so that your messages
don't get dropped by the moderator system and so that you can receive
the responses.
https://lists.apache.org/thread.html/3e048af8e7c8adaa0d234913b061adbfbd5896e2cba71b78031ec3ac@%3Cdev.poi.apache.org%3E

On Wed, May 10, 2017 at 12:06 AM, Ramani Routray <[hidden email]> wrote:

> I have a Microsoft word (.docx) file and trying to retrieve the comments and
> it's associated highlighted text. Can you pls help.
>
> Attaching picture of the sample word document and the java code for
> extracting the comments. [ A file with a line "My name is John". The word
> "John" is highlighted with a comment "Noun" ]
>
> I am able to extract the comments (Noun, Adjective). I would like to extract
> the highlighted text associated with the comment from the word document
> "Noun" (Noun = John, Adjective = great)
>
>
> FileInputStream fis = new FileInputStream(new File(msWordFilePath));
>     XWPFDocument adoc = new XWPFDocument(fis);
>     XWPFWordExtractor xwe = new XWPFWordExtractor(adoc);
>     XWPFComment[] comments = adoc.getComments();
>
>
>     for(int idx=0; idx < comments.length; idx++)
>     {
>         MSWordAnnotation annot = new MSWordAnnotation();
>         annot.setAnnotationName(comments[idx].getId());
>         annot.setAnnotationValue(comments[idx].getText());
>         aList.add(annot);
>
>
>     }
>
>
> regards,
> Ramani
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...