+ Start a Discussion
tvance007tvance007 

Field containing text with CR wraps in visualforce

I have a field that has text in it that I am outputting to a PDF using visualforce and the text is wrapping and not holding the CR formatting.  Any suggestions on how to keep the formatting of the text when displayed in visualforce?

 

Thanks,
Terry

Best Answer chosen by Admin (Salesforce Developers) 
mtbclimbermtbclimber

are you using apex:outputField to render the value? If not, can you?

All Answers

mtbclimbermtbclimber

are you using apex:outputField to render the value? If not, can you?

This was selected as the best answer
Alderete_SFDCAlderete_SFDC

Can I ask for a little more detail on the issue? Is this a plain text field that you want to convert to PDF? And, when you say that you're "outputting a PDF using Visualforce", do you mean that you are simply using a Visualforce page like this:

 

<apex:page standardController="MyObject" renderAs="pdf">

  {!myobject.textfield}

</apex:page>

 

If your Visualforce page is more complex than this, can you post it, or a simplified version?

 

What do you see in your browser when you take out the renderAs attribute? Is the output formatted the way you expect?

TV007TV007

Thanks for the reply. I actually forgot about this. This was a table of values where I was just specifying the field name ( <td>{!line.PricebookEntry.Name}</td> ) and not using the apex:outputField like I had used in other areas of the page. I used that and it works great. Thanks

ssikorassikora

The apex:outputfield tag does indeed honor the Carriage Returns as part of renderAs. Thanks for your help.