java.lang.IllegalStateException on Document.updateFields()

I’m running Aspose.Words.jdk15.jar version 10.6 and keep getting this exception when calling the updateFields() method on a Document.
The document is created in Word and modified a bit by our code.
It does not happen for all documents we process, but for some.

I cannot upload this specific document due to the contents therein, but I really need some help in understanding what causes this.
If you can provide any hints from this stack trace, I would be most thankful.

If you can’t see anything from this stack trace, I can try to remove stuff from the document until I can upload it.

java.lang.IllegalStateException
at com.aspose.words.arz.b(SpanField.java:449)
at com.aspose.words.arz.v(SpanField.java:196)
at com.aspose.words.arz.update(SpanField.java:154)
at com.aspose.words.wc.c(LayoutDocument.java: 230)
at com.aspose.words.wc.a(LayoutDocument.java: 206)
at com.aspose.words.wc.a(LayoutDocument.java: 179)
at com.aspose.words.wc.a(LayoutDocument.java: 56)
at com.aspose.words.Document.updatePageLayout(Document.java: 1461)
at com.aspose.words.ld.perform(ExternalActionUpdateLayout.java: 25)
at com.aspose.words.os.execute(FieldUpdateExecutionItem.java: 79)
at com.aspose.words.ov.if(FieldUpdater.java: 97)
at com.aspose.words.ov.updateFields(FieldUpdater.java: 60)
at com.aspose.words.Range.updateFields(Range.java: 172)
at com.aspose.words.Document.updateFields(Document.java: 1047)

Hi
Thanks for your request. Could you please attach the document you are getting problem with? I will check it on my side and provide you more information.
Best regards,

Attached file.

This code throws an exception:

Document doc = new Document(new FileInputStream("anonymized.doc"));
doc.updateFields();

We have removed things from the file until it works.
I attach a minimal file that causes the exception on updateFields.
It seems to be the advanced table in the header that causes this.
If I remove the header table, it suddenly works again.

Is this a bug, or what is the real problem with the table?
Is there something we can do with it, to keep the formatting, but not cause the problem?

(There used to be text/images in all cells of the header table, but I removed all sensitive information from it.)

Hi
Thank you for reporting this problem to us and for the additional information. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed.
Best regards,

You probably know it by now, but the problem is FieldStart/FieldEnd without any actual text in between. Those we can (programatically) remove. Not sure how someone managed to create them in the first place.

Hello
Thank you for additional information. You will be notified as soon as it is fixed.
Best regards,

Hello,
We have the same problem. Could you please inform me about the status of the issue? Will it be fixed for the next Aspose.Words version?
Best regards, Evgeniy

Hi Evgeniy,
Thanks for your request. The problem reported in this thread is not resolved yet. Could you please attach your sample document here for testing? We will check it in order to make sure the problem is the same.
Best regards,

Hi Alexey,
Please find the document attached.
Best regards, Evgeniy

Hi Evgeniy,
Thank you for additional information. I managed to reproduce the problem on my side. The exception occurs when you call UpdateFields after executing mail merge. Your request has been linked to the appropriate issue. We will let you know once it is resolved.
Also, I would bring your attention to the fact that it is not necessary to call UpdateFields after executing mail merge because MailMerge.Execute method internally calls this method. So if you do the following in your code:

  1. Execute Mail Merge with Regions
  2. Execute simple mail Merge
  3. Call UpdateFields method.

Then the third action is redundant.
Best regards,

The issues you have found earlier (filed as WORDSNET-5457) have been fixed in this .NET update and in this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as WORDSNET-5508) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.