Free Support Forum - aspose.com

Find the comment start and end range

Dear Team,

I am using java aspose word 21.3 jdk. I want to extract the documents comment start and end range position, please suggest the solution.

sample.zip (68.8 KB)

Thanks in advance,
Best regards,
Kesavaraman

@keshav07

Could you please share some detail about position of start and end rage? What is your expected output? We will then provide you more information about your query.

image.png (11.2 KB)

If you see in the attached image the comment was provided for sentence “Northern hemisphere” . I want to get comment starting index position value and comment ending index position value. is it possible ?

@keshav07

As per our understanding, you want to get the X,Y location of comment start and end on the page.

The layout APIs allow to access information such as on what page and where on a page particular document elements are positioned, when the document is formatted into pages. Please use the following code example to get the position of comment start and end index. Hope this helps you.

Document doc = new Document(MyDir + "LEOUT_EPA_2100022.docx");

Node node = doc.getChild(NodeType.COMMENT_RANGE_START, 0, true);

LayoutCollector collector = new LayoutCollector(doc);
LayoutEnumerator enumerator = new LayoutEnumerator(doc);

Object renderObject = collector.getEntity(node);
enumerator.setCurrent(renderObject);

System.out.println(enumerator.getRectangle());

node = doc.getChild(NodeType.COMMENT_RANGE_END, 0, true);
renderObject = collector.getEntity(node);
enumerator.setCurrent(renderObject);

System.out.println(enumerator.getRectangle());

Dear Team,

Thanks for the solution, i will try this.

Best regards,
Kesavaraman

Hi Tahir,

Sorry for the inconvenice that i created here.

The index position that the code produce aren’t not match with the document . it produce some floating indexes which not matching the comment position in the document.

My case is

  1. I want to iterate all comment that are present in the document.
  2. find the position where the particular comments actually start and poisition actually end.
    3)Extract the comments along with current paragraph.

for example
Psychotic disorders, such as schizophrenia, are among the most severe and debilitating conditions in psychiatry, and in all of medicine.

In the above paragraph considere the bold word (disorders) has comments means i want that starting comment node value and ending comment node value which means (disorder word position is starting comment node value is 9 and endding comment node value is 19)

I want that comment start index and comment end index , particular comment and current paragraph. is that posible

Best regards,
Kesavaraman

@keshav07

The comment is not for word disorders rather it is for ’ all of medicine. Please check the attached image. comment detail.png (15.4 KB)

Could you please share how are you getting these values (9 and 19) from the document?

Unfortunately, your requirement is not clear enough. So, please share some more detail about your requirement along with expected output. Please also share how are you getting the expected output value using MS Word.