I am fairly new to the visualforce development. I created a page which is displaying nicely. While rendering the page with renderas="PDF" i want a particular div tag to hide:

<div id="TextCounter">200 characters remaining</div>

wondering if we can provide some conditions before rendering as pdf using some kind of boolean variable.

  • Hi Neel, welcome to SFSE. Are you rendering your page into PDF only some of the time by using the getContentAsPDF() call? If not, how are you doing that conditionally? (Please edit your question to add some context).
    – David Reed
    Commented Jan 23, 2019 at 16:45
  • Please try applying this css styling to that div (style="display: none;")
    – Nithesh N
    Commented Jan 23, 2019 at 17:52
  • You can use <apex:outputPanel> tag instead with layout="block" so that it renders as a div. Then you can use the rendered attribute to control when to show it and when to hide.
    – Aayush K
    Commented Jan 23, 2019 at 21:32

1 Answer 1


It worked with the CSS styling suggested by Nitesh N in a comment:

<div id="TextCounter" style="display: {!IF(printableLead == true, 'none', 'block')};">200 characters remaining</div>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .