Locate text in a word document

Hello,

I’m looking for a java class to locate texte in a word document, like PDF class TextFragmentAbsorber can.

Best regards

Fabien

@fabien.levalois

The Aspose.Words.Layout namespace provides classes that 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.

You can use LayoutCollector.GetEntity method to get an opaque position of the LayoutEnumerator which corresponds to the specified node. All text of the document is stored in runs of text. If you need to navigate to a Run of text then you can insert bookmark right before it and then navigate to the bookmark instead.

We suggest you please read the members of LayoutCollector and LayoutEnumerator classes and read about Aspose.Words’ DOM from here.
Aspose.Words Document Object Model

Hi tahir

thank you for your help

Are they the same layout for Excel and PowerPoint

Best regards
Fabien

@fabien.levalois,

In Microsoft Excel, users can search for cell(s) that contain specific data via Find/Replace options. Aspose.Cells also supports the same feature, see the document with examples for your reference:

Hope, this helps a bit.

@fabien.levalois,

From Aspose.Slides perspective, the API allows to extract the text from text frames on individual slide level and also on entire presentation level. You can replace the text if desired too during extraction. I suggest you to please visit this documentation link for your kind reference in this regard.

Hi Mudassir,

Thanks for your help, I try this morning the sample code to find the coordinate of the pargrah.
i do that with this fonction para.getRect(). It seem that coordinate not is calculate from the bottom left corner.

How can i calculate the good coodinate from the left corner

Thanks for your help

Best regards

Fabien

Hi Amjad

Thank you for help,

I don’t find any process to find coordinate of a text like the method layoutEnumerator.getRectangle() do for word document.

Do you tell me if it’s possible to do that with Aspose java library

Best regards

Fabien

@fabien.levalois,

I am not sure about your requirements. Could you elaborate more and provide some sample Excel file (containing the text in some cell) to denote how you want to locate? Do you need x, y coordinates and width, height of cell (containing your desired text) in e.g pixels?

If this is true (as above), you may implement DrawObjectEventHandler interface to write your own codes in its Draw method to override it. See the document for your reference:

Hello
The word text extraction is working correcty. But i need to extract only text from one page of my word document
layoutEnumerator read first item of the first to the last item of the last page.
is it possible to read only item of a specifique page
I attach my java class
AsposeLocateWordText.zip (1.1 KB)
Best regard

Fabien

@fabien.levalois

We are looking into this scenario and will get back to you shortly.