We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Conditionally hidding elemnts

I need to show/hide a table in the document.

Of course I can make empty table and use this.
But it is more simple to use the construction like
Is it possible or not?


Thanks for your inquiry. Yes of course it is possible. If you need to conditionally show/hide part of content in your document, then you should consider using IF fields. For instance, please see the attached template. If you press Alt+F9 you will see field codes. If condition is true you will see the first text if false the second. Here is a simple code I used for testing:

Document doc = new Document("in.doc");

doc.MailMerge.Execute(new string[] {"test"}, new object[] {"true"});


Hope this approach could help you.

In additional, you can do not use mergefields in IF fields at all. I put a mergefield just to demonstrate how IF fields work.

Please follow the link to learn more about IF fields:


Best regards,

I’ve read it.

And this is not that I want. It puts only text depends on condition not the elements.


Thanks for your inquiry. You can put anything you want inside your IF field (paragraphs, tables etc).

Best regards,

Can you give an example where table or image inside IF?


Thanks for your inquiry. Please see the attached template.

Best regards,

Ok, I did it. But I have taken a strange result.

In the result I see the data only after clicking alt+F9.
See template and report in attachments.


Thank you for additional information. Have you called UpdateFields method? Maybe in your case it is enough just call UpdateFields() to evaluate IF field.


Best regards,

Thanks. It helps.