Free Support Forum -

Invalid document model - when reading out Hyperlinks

Goodmorning Aspose,

Following the advise I got from ticket: Replacing Hyperlink text over multiple paragraphs I’m using the Fields to find all the Hyperlinks.
But for the uploaded file, this results in the error:

java.lang.RuntimeException: java.lang.IllegalStateException: Invalid document model. Operation can not be completed.
at com.aspose.words.FieldCollection$zzZ.zzZwz(Unknown Source)
at com.aspose.words.FieldCollection$ Source)

Code te replicate the issue:

Document aAsposeDoc = new Document(lFileName);
for ( Field lField : aAsposeDoc.getRange().getFields() ) {   // exception is thrown here
    if ( lField.getType() == FieldType.FIELD_HYPERLINK ) {
           FieldHyperlink lHyperlinkField = (FieldHyperlink) lField;

Version: Aspose Word Java 20.3 & 21.3.0 (10.0 KB)



We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-22087. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.