I need to render pdf page with content from object. To do so I put <apex:detail> element in page and it is working, but its showing other elements from page layout that I don't need in pdf. I tried to apply styles, but I noticed that they working only if I indicate class explicitly. For example:

.pbSubheader {
    display: none;

this style will hide all elements with class .pbSubheader, but if I won't to hide elements with more complicated logic then this styles are ignored, for example:

.pbBody .pbSubsection:not(:last-child) {
    display: none;
    visibility: hidden;

this style will not work. How can I achive this?

  • Add an "id" to your tag and use CSS selectors when applying your style.
    – Jac Uy
    Jun 1 '17 at 8:53
  • We don't have access to what <apex:detail> will generate Jun 1 '17 at 9:12

You can try to set some variable to true, only when you render it as pdf, and use that variable in rendered attribute of those elements which you want to hide.

  • I'm not sure I understand it. We don't have access to what <apex:detail> will generate. Jun 1 '17 at 8:47
  • Ohkk.. then instead of only main class, you will need to check exact hierarchy of classes being used on those elements which you want hide. (Parent to child elements) Jun 1 '17 at 8:54
  • But I need to use additional conditions like :last-child, :first-child Jun 1 '17 at 9:11
  • 1
    @user2452483 the css selectors you are using like :first-child and :last-child are from css3 and salesforce pdf engine does not support css3. So you should come up with css2.1 selectors for the elements you are trying to hide.
    – javanoob
    Jun 1 '17 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.