Issue inserting custom fields in header

Hi,
There seems to be any issue with the insertion of custom formula fields as part of the header/footer. The fields are getting inserted properly, but then, they also seem to get updated automatically if they’re part of the header/footer, unlike the fields in the body, and are displaying syntax error. I’ve been utilizing this chunk of code to insert the field in the header/footer.

DocumentBuilder db = new DocumentBuilder(doc); db.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY); db.insertField(" = HsComment|begin|111111| “,”"); db.moveToHeaderFooter(HeaderFooterType.FOOTER_PRIMARY); db.insertField(" = HsComment|end|111111| “,”");
db.getDocument().save(…);

Attaching the generated document for your reference. Please suggest a way to avoid the auto-updation (or whatever issue is causing this behaviour). Thanks.

Hi Praneeth,

Thanks for your inquiry. I tested the scenario and have managed to reproduce the same problem on my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-10433. Our development team will further look into the details of this problem and we will keep you updated on the status of correction. We apologize for your inconvenience.

Best regards,

Hi Praneeth,


Thanks for being patint. Regarding WORDSNET-10433, our development team has completed the work on your issue and has come to a conclusion that this issue and the undesired behaviour you’re observing is actually not a bug. So, we have closed this issue as ‘Not a Bug’.

Aspose.Words doesn’t update fields in header/footer while saving to docx, MS Word automatically updates them when opening the document. You should avoid using formula field for custom purpose. However, MS Word and Aspose.Words have different error text for formula field with following code:

MS Word: !Syntax Error, |
Aspose.Words: !Undefined Bookmark, HSCOMMENT|BEGIN|111111|

If we can help you with anything else, please feel free to ask.

Best regards,