You need to sign in to do that
Don't have an account?
Data
BR tags not rendering correctly in visualforce PDF.
I've created a PDF visualforce page for a purchase orders application i've created but when I pull out an address the address appears in the PDF as:
my house<br>My Address line 1<br>My address line 2<br>state<br>country<br>zipcode
and its not converting the <br> tags to new lines, how can I make it do that?
Thanks
You could use this in your pdf page so that Salesforce doesn't try escaping the tags (I assume that's the problem here):
<apex:outputText value="{!Purchase_Order__c.Ship_To_Address__c}" escape="false" />
Although be warned - if you try packaging this up Salesforce does tend to tell you to take escape="false" out when sending an app for security review.
I've also found that using this works as well for some reason that doesn't make sense to me:
<apex:page renderAs="pdf" ContentType="application/pdf">
{!Purchase_Order__c.Ship_To_Address__c} </apex:page>
All Answers
Not sure if this works, but give it a go
<p>my house</p>
<p>My Address line 1</p>
<p>My address line 2</p>
<p>state</p>
<p>country</p>
<p>zipcode</p>
<p>country</p>
<p>zipcode</p>
cheers,
Wes
The problem is the address comes out from salesforce as one field:
{!Purchase_Order__c.Ship_To_Address__c}
You have a few options.
1. Create an object Ship_To_Address__c with fields for each address line. Create a lookup relationship between this object and Purchase_Order__c.
2. Create multiple address fields in the Purchase_Order__c object e.g. Purchase_Order__c.ship_to_address_line1__c
3. Capture the address as the HTML with <br/> or <p>.
Cheers,
Wes
You could use this in your pdf page so that Salesforce doesn't try escaping the tags (I assume that's the problem here):
<apex:outputText value="{!Purchase_Order__c.Ship_To_Address__c}" escape="false" />
Although be warned - if you try packaging this up Salesforce does tend to tell you to take escape="false" out when sending an app for security review.
I've also found that using this works as well for some reason that doesn't make sense to me:
<apex:page renderAs="pdf" ContentType="application/pdf">
{!Purchase_Order__c.Ship_To_Address__c} </apex:page>
Brilliant thanks a lot. Strange about the ContentType...
Hey
When you say line breaks do you mean '\n'? Because these don't do anything. You'll have to use html markup.
Cheers,
Wes
yes and I need to a way to translate the \n to <br> in the pdf. Its an invoice where a line item could have a bit of a description for example a spec of a computer. So the sales rep has put in the text area for the product item:
1 x 1GB Dimm
2 x 500gb hard disk
3 x sound...
etc but it comes out on the PDF as:
1 x 1GB Dimm2 x 500gb hard disk3 x sound...
try <apex:inputTextArea richtext="true"/>. That might work. Otherwise you can use a Wysiwyg editor and that will output HTML for you.
Wes
You could try and use {!SUBSTITUTE(myField, '\n', '<br />')}
Not sure if it'll work though...