Join the Team Forms community

Updated 2 months ago

how to hide a component on the PDF if the input is empty

At a glance

The community members discuss how to hide a component in a PDF if the value/input is empty. One community member suggests using the advanced conditional feature to dynamically hide the component based on the instance.isHtmlRenderMode() and instance.getValue() functions. Another community member provides an update that there is now a "PDF Visibility" option available for all components, which allows selecting between visible, hidden, and "Hide if empty". The answer states that to hide a component in the PDF if the input is empty, the "Hide if empty" option can be selected.

how can i hide the component in pdf if the value/input is empty

Marked as solution

UPDATE

There is now a "PDF Visibility" option available for all components. This option will allow you to select between visible, hidden and Hide if empty. So, to hide a component in the PDF if the input is empty you can simply tick the "Hide if empty" option.

View full solution
A
2 comments

To hide a component in the generated pdf only when it has no value you can use the advanced conditional feature to dynamically hide the component.


The instance.isHtmlRenderMode() function will return true for PDF rendering and the instance.getValue() function will return the value of the component. Combining this into a conditional expression will allow you to hide the component in the PDF if there is no response to it as shown below.


JavaScript
if(instance.isHtmlRenderMode() && !instance.getValue())
    show = false

UPDATE

There is now a "PDF Visibility" option available for all components. This option will allow you to select between visible, hidden and Hide if empty. So, to hide a component in the PDF if the input is empty you can simply tick the "Hide if empty" option.