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

Free Support Forum - aspose.com

Document.UpdateFields throws Exception using Java | Invalid Document Model

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$zzZ.next(Unknown 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
Aspose-hyperlink-Invalid_document_model.zip (10.0 KB)

Regards,
Inception

@inceptionEhv

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.

The issues you have found earlier (filed as WORDSNET-22087) have been fixed in this Aspose.Words for .NET 21.5 update and this Aspose.Words for Java 21.5 update.

With Aspose Words: 21.5.0 the problem is resolved for the Hyperlinks, but now I’m having an exception when I save the document.

I’m using the folowing code:

Document lDocument = new Document( lFilePath );
lDocument.updateFields();
lDocument.updatePageLayout();
lDocument.updateTableLayout();
lDocument.save( lSavePath );

Results in the following error:

com.aspose.words.internal.zzYE: Could not create the bitmap with the specified parameters. Possible lack of system resources.: Parameter is not valid. FileFormat =0
at com.aspose.words.internal.zzYS.(Unknown Source)
at com.aspose.words.internal.zzYS.(Unknown Source)
at com.aspose.words.internal.zzYS.(Unknown Source)
at com.aspose.words.internal.zzKL.zzY(Unknown Source)
at com.aspose.words.internal.zzKL.zzZy(Unknown Source)
at com.aspose.words.zzZGE.zzZT(Unknown Source)
at com.aspose.words.zzZGE.setImageBytes(Unknown Source)
at com.aspose.words.ImageData.setImageBytes(Unknown Source)
at com.aspose.words.zzZW8.zzZoY(Unknown Source)
at com.aspose.words.zzZW8.zzR(Unknown Source)
at com.aspose.words.FieldIncludePicture.zzZpy(Unknown Source)
at com.aspose.words.zzZUY.zzp(Unknown Source)
at com.aspose.words.zzZUY.zzr(Unknown Source)
at com.aspose.words.zzZUY.zzJ(Unknown Source)
at com.aspose.words.zzZUY.zzM(Unknown Source)
at com.aspose.words.zzZUY.zzP(Unknown Source)
at com.aspose.words.zzZUY.zzX(Unknown Source)
at com.aspose.words.zzZUY.zzXV(Unknown Source)
at com.aspose.words.zzZUY.zzZ(Unknown Source)
at com.aspose.words.zzZUY.zzYX(Unknown Source)
at com.aspose.words.Range.updateFields(Unknown Source)
at com.aspose.words.Document.updateFields(Unknown Source)

@inceptionEhv

We have logged this problem in our issue tracking system as WORDSNET-22385. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-22385) have been fixed in this Aspose.Words for .NET 21.8 update and this Aspose.Words for Java 21.8 update.