Please see attached “DocTemplateVariableScopeIssue.docx” document template which declares a “myHeaderVariable” variable in the document header to be used with the Linq Reporting Engine inside the document. In version 21.7 of Aspose.Words, this variable could be used in the body of the document without a problem, see attached, generated document “DocTemplateVariableScopeIssue_Generated_v21.7.docx” and screenshot “DocTemplateVariableScopeIssue_Generated_v21.7.png.” In version 21.10 of Aspose.Words, this functionality broke, so we have many document templates that do not work anymore. See attached, generated document “DocTemplateVariableScopeIssue_Generated_v21.10.docx” and screenshot “DocTemplateVariableScopeIssue_Generated_v21.10.png.” (generated from the same “DocTemplateVariableScopeIssue.docx” document template).
Can you please fix this bug or suggest a workaround.
@ted-1,
We have tested the scenario and managed to reproduce the same issue at our side. This issue appears because of new template reader’s behavior, added in version 21.9. Starting from this version, body of the document processes before headers/footers, so you can’t use variables, declared in document header, in document body.
For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET - 22967. You will be notified via this forum thread once this issue is resolved.
@ted-1,
The issue is already resolved in the current codebase. The fix will be available in the next version of Aspose.Words, which is to be released in about a week.
After Aspose.Words 21.12 is released, you can apply ReportBuildOptions.UseLegacyHeaderFooterVisiting to get results compatible with older versions of Aspose.Words.