Remove merge fields space and table that contain null value

want to remove the extra space and table using java code,
please refer following image, I want to remove (remove whole line, because now if value is null it’s contain whole line) if ‘stepInputData’ is ‘null’ and and I want to remove the ‘sharedTc’ table through the code and that space as well, let me know if any doubt

@kalpeshAspose1997 we are working to provide the best solution for you. Additionally, will be helpful if you provide your template file.
Also, you can try using MailMergeCleanupOptions to remove unnecessary fields and regions from the template upon executing mail merge. Please see our documentation for more information.
https://docs.aspose.com/words/java/clean-up-before-or-during-mail-merge/