How to generate correct page numbers and Table of Contents in the conditionally appended templates
I am appending a landscape page and a portrait page to the main template page.
The landscape page is going to get integrated conditionally.
Please check the following workspace and let us know how to generate the correct page numbers and table of contents.
You can't merge the TOC as pdf utils operation, because it would run before the script. It is not aware of the landscape template you add in the script. So you need to merge the TOC in the script as well after you've appended the landscape template.
Here is the updated playground