I've run into an error that I can't understand or resolve. In a word document I have the string "<start>pepe<end>", nothing more. I use findPattern to locate "<start>" and "<end>". This does it fine but then I have to grab the ranges and use "getAsOneRange" for each of them. With "<start>" it works, but with "<end>" a null pointer error is thrown. I have also tried with the "getAsRange" and "getRanges" methods and I get the same error.
The most curious thing is that I have been testing Spire.Doc for several days and I have other documents with much more content with many marks to search for and they work well. I ran into this error when in the large document, I put the marks inside a table cell. When trying to reproduce the error in a simpler document, I arrived at the document that I am attaching, which can not be simpler.
The code:
Document document = new Document();
document.loadFromFile("PruebaWord con tabla.docx");
TextSelection startSelection = document.findPattern(Pattern.compile("<start>"));
TextSelection endSelection = document.findPattern(Pattern.compile("<end>"));
TextRange startRange = startSelection.getAsOneRange();
TextRange endRange = endSelection.getAsOneRange();