We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose Ranges

Hello,

We currently have a process that utilizes the word interop assemblies to load and convert word documents to SGML. Part of the process is building up dictionaries of objects that store start and end positions of various things (like all underlined words within a range, all bolded words within a range, among other things). We would like to utilize Aspose.Words for this process for better performance as well as removing the need to have MS Word installed. Is there a way in Aspose.Words to get the starting and ending character positions of a Range (or node)?

Thanks!

Hi Brad,


Thanks for your interest in Aspose.Words. Yes, you can easily meet this requirement. Please see the following code:

Document doc = new Document(MyDir + @“in.docx”);

doc.JoinRunsWithSameFormatting();

foreach (Run run in doc.GetChildNodes(NodeType.Run, true))

{

string text = run.ToString(SaveFormat.Text);

Console.WriteLine("Start character of this Run: " + text[0]);

Console.WriteLine("End character of this Run: " + text[text.Length - 1]);

}


Also, you can find many useful articles in Aspose.Words API documentation.

I hope, this helps.

Best regards,