Answers.Body: <p>Try to use  as below which does the job </p>
  
  <pre><code>&lt;div&gt;{contact.addressee}&lt;/div&gt;
  &lt;div&gt;{contact.street_address}&lt;/div&gt;
  &lt;div&gt;{contact.supplemental_address_1}&lt;/div&gt;
  &lt;div&gt;{contact.supplemental_address_2}&lt;/div&gt;
  &lt;div&gt;​{contact.city}&lt;/div&gt;
  &lt;div&gt;{contact.postal_code}&lt;/div&gt;
  </code></pre>
  
  <p>OR </p>
  
  <p>I am not sure about replacing the in-build token using IF statement </p>
  
  <p>But you can create an Address block token on your own where you can remove blank lines - and you can use address block token in the PDF</p>
  
  <p><a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Customized+%28and+Custom%29+Tokens" rel="nofollow noreferrer">http://wiki.civicrm.org/confluence/display/CRMDOC/Customized+%28and+Custom%29+Tokens</a></p>
  
  <p>I guess this help - if you need more details please let me know - thanks </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-13T18:53:13.293Z
Answers.Text: creating a new token requires coding and I was hoping the answer would be simpler than that! I see some references to smarty tokens and conditional things being not available in labels with the implication that they are available in pdf letters....
Answers.UserDisplayName: Mick Kahn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-28T10:07:08.113Z
Answers.LastActivityDate: 2017-10-27T11:31:40.057Z
Answers.LastEditDate: 2017-10-27T11:31:40.057Z
Answers.UserDisplayName: Ramesh - ARTECH Consultancy
Answers.Body: <p>Aha - worked out how to do this. You need to use smarty for conditional logic. See <a href="https://docs.civicrm.org/sysadmin/en/latest/config/message-templates/" rel="nofollow noreferrer">https://docs.civicrm.org/sysadmin/en/latest/config/message-templates/</a> to see how to turn on smarty for mail/pdf templates. I also used <a href="https://www.smarty.net/docs/en/language.function.capture.tpl" rel="nofollow noreferrer">https://www.smarty.net/docs/en/language.function.capture.tpl</a> to work out how to do it.</p>
  
  <p>Then in the template you need something like:
  <br/> <br/>
  {capture assign=temp}{contact.supplemental_address_1}{/capture}<br/>
  {if $temp ne ""} <br/>
  {$temp} XXX <br/>
  {/if}<br/></p>
  
  <p>But where I have XXX above there is line break HTML markup (Can't work out how to get that through the markup for stack exchange. Hope that makes sense!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-13T22:01:25.370Z
Answers.LastActivityDate: 2017-10-13T22:11:21.053Z
Answers.LastEditDate: 2017-10-13T22:11:21.053Z
Answers.UserDisplayName: Mick Kahn
Body: <p>We have an address block on some pdf templates in CiviCRM some contacts have address2 or address3 lines while other do not.</p>
  
  <p>Using the normal tokens we end up getting blank lines and the address block looks messy.</p>
  
  <p>Has anyone found a way of conditionally formatting the address block to not create these blank lines?</p>
  
  <p>I was looking for some IF(Token not NULL THEN add Token and carriage return ELSE nothing) but can't find any solution online.</p>
  
  <p>Thanks,</p>
  
  <p>Dave</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-27T17:33:17.050Z
Comments.Text: You should be able to do this by entering a curly brace with a space in it { }.  Could you please update this ticket with your current address block token?
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-27T20:51:19.227Z
Comments.Text: Not sure I follow you in terms of how you would use { }? Current block is: {contact.addressee}
  {contact.street_address}
  {contact.supplemental_address_1}
  {contact.supplemental_address_2}
  ​{contact.city}
  {contact.postal_code}
  {contact.postal_greeting}
  
  But if either supplemental address fields are blank you get a blank row. Thanks - PS - the normal carriage returns have been removed in this comment.
Comments.UserDisplayName: Dave
Tags: <tokens><pdf><message-templates>
Title: Removing Carriage returns after a blank address field?
ThreadText: # Removing Carriage returns after a blank address field?
  
  (Asked by: username_0 on 2015-10-27)
  
  We have an address block on some pdf templates in CiviCRM some contacts have address2 or address3 lines while other do not.
  
  Using the normal tokens we end up getting blank lines and the address block looks messy.
  
  Has anyone found a way of conditionally formatting the address block to not create these blank lines?
  
  I was looking for some IF(Token not NULL THEN add Token and carriage return ELSE nothing) but can't find any solution online.
  
  Thanks,
  
  username_0
  
  **Tags:** tokens, pdf, message-templates
  
  > **Comments:**
  > **username_1**: You should be able to do this by entering a curly brace with a space in it { }.  Could you please update this ticket with your current address block token?  
  > **username_0**: Not sure I follow you in terms of how you would use { }? Current block is: {contact.addressee} {contact.street_address} {contact.supplemental_address_1} {contact.supplemental_address_2} ​{contact.city} {contact.postal_code} {contact.postal_greeting}  But if either supplemental address fields are blank you get a blank row. Thanks - PS - the normal carriage returns have been removed in this comment.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2015-10-28. Score: 3
  
  Try to use as below which does the job
  
  ```
  <div>{contact.addressee}</div>
  <div>{contact.street_address}</div>
  <div>{contact.supplemental_address_1}</div>
  <div>{contact.supplemental_address_2}</div>
  <div>​{contact.city}</div>
  <div>{contact.postal_code}</div>
  
  ```
  
  OR
  
  I am not sure about replacing the in-build token using IF statement
  
  But you can create an Address block token on your own where you can remove blank lines - and you can use address block token in the PDF
  
  <http://wiki.civicrm.org/confluence/display/CRMDOC/Customized+%28and+Custom%29+Tokens>
  
  I guess this help - if you need more details please let me know - thanks
  
  > **Comments:**
  > **username_3**: creating a new token requires coding and I was hoping the answer would be simpler than that! I see some references to smarty tokens and conditional things being not available in labels with the implication that they are available in pdf letters....  
  
  ---
  
  ### Answer by username_3 on 2017-10-13. Score: 0
  
  Aha - worked out how to do this. You need to use smarty for conditional logic. See <https://docs.civicrm.org/sysadmin/en/latest/config/message-templates/> to see how to turn on smarty for mail/pdf templates. I also used <https://www.smarty.net/docs/en/language.function.capture.tpl> to work out how to do it.
  
  Then in the template you need something like:
    
     
  {capture assign=temp}{contact.supplemental\_address\_1}{/capture}  
  {if $temp ne ""}   
  {$temp} XXX   
  {/if}
  
  But where I have XXX above there is line break HTML markup (Can't work out how to get that through the markup for stack exchange. Hope that makes sense!
  
  
  ---
  
  