I would like to put some known text in a Word doc and programmatically find it's x,y location with respect to the document or page using .NET. Is that possible? I was looking at using the OpenXML SDK but I don't see a path to getting that to work. Or could I use something like an image or bookmark to do this? I'm evaluating Aspose and curious if it can help with this.
Ultimately I'm trying to save the Word doc as a PDF or image (using a library like Aspose) and overlay some content at that location. Any ideas are appreciated.
Thanks for your inquiry. Unfortunately, Aspose.Words does not support the requested feature at the moment. However, we had already logged this feature request as WORDSNET-2978 in our issue tracking system. You will be notified via this forum thread once this feature is available.
Moreover, you can use image or bookmark in your document to achieve your requirements. You can navigate the DocumentBuilder cursor to a different location in a document using various MoveToXXX methods.
Thanks. If we were to convert the word doc to a PDF and then try to locate text or a marker of some kind, would that be supported by Aspose.PDF? Would it need to be a barcode or bookmark or something else to make sure it found it reliably? Maybe this is better posted in the other forums.
Thanks for your inquiry. Your query is more related to Aspose.PDF component. I am moving this thread to Aspose.PDF forum and my colleagues from Aspose.PDF team will reply you shortly.
I am pleased to share that Aspose.Pdf for .NET supports the feature to search the text inside PDF document and get its coordinates/dimensions. Please visit the following link for further details on Search and Get Text Segments from All Pages of PDF Document
You can also find and replace text inside PDF document and also add image/text over particular location. Please visit the following link for further information on
The Search and Get Text Segments from All Pages of PDF Document example seemed to be what I am looking for. Can you clarify one thing for me? Is the YIndent of the TextSegment relative to the bottom of the page? I assumed x,y would be top,left based and I wasn’t sure if it would be relative to the document or the page. It is looking like it is relative to the bottom left of the page it is on. Is that correct? I’m obviously new to the API so I’m not sure if I’m missing something. The documentation for both XIndent and YIndent say that they are the X coordinate.
And would these be the way to get the size of each page:
The Search and Get Text Segments from All Pages of PDF Document example seemed to be what I am looking for. Can you clarify one thing for me? Is the YIndent of the TextSegment relative to the bottom of the page? I assumed x,y would be top,left based and I wasn’t sure if it would be relative to the document or the page. It is looking like it is relative to the bottom left of the page it is on. Is that correct?
The YIndent of the TextSegment is calculated from the bottom of the page. The XIndent and YIndent starts from bottom left of the page.
bdoc7aspose:
The documentation for both XIndent and YIndent say that they are the X coordinate.
In case you also want to find position of text in a word document then please create a separate topic in Aspose.Words forum and we will guide you accordingly.
You can get the position of text in a Word document by using Aspose.Words. In this case, we suggest you following solution.
In your case, we suggest you please implement IReplacingCallback interface and find the desired text. Please read the following article. Find and Replace