poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ramani Routray <routr...@gmail.com>
Subject Java (Apache POI) : How to retrieve comment/annotation and associated highlighted text from Microsoft Word?
Date Wed, 10 May 2017 07:06:39 GMT
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();



View raw message