An apex:outputField works fine. Here is part of a PDF Visualforce page:
<tr>
<th class="bordered">Offered</th>
<th class="bordered">Offered Date</th>
<th class="bordered">Accepted</th>
<th class="bordered">Accepted Date</th>
<th class="bordered">Description</th>
</tr>
<apex:repeat value="{!rehabilitations}" var="item">
<tr>
<td class="bordered"><apex:outputField value="{!item.Offered__c}"/></td>
<td class="bordered"><apex:outputField value="{!item.OfferedDate__c}"/></td>
<td class="bordered"><apex:outputField value="{!item.Accepted__c}"/></td>
<td class="bordered"><apex:outputField value="{!item.AcceptedDate__c}"/></td>
<td class="bordered"><apex:outputField value="{!item.Description__c}"/></td>
</tr>
</apex:repeat>
that outputs this:
The apex:outputField renders a checked or unchecked checkbox image that carries through to the PDF.
The images used are /img/checkbox_checked.gif and /img/checkbox_unchecked.gif. If your checkboxes are not fields, you could reference the images yourself in an IF.
As per Salesforce documentation:
If multiple spaces are required for some reason (e.g. formatting purposes), the
entity must be used. However, in order for this entity to not itself be HTML escaped by apex, a proper "escape" option must be specified. Examples:
a) For the outputText
tag, the "escape" attribute must be set to false. e.g.:
Controller:
comment = new CaseComment(CommentBody = 'There are 3 spaces between each word.\r\n\r\nThere is a blank line before this one.');
Apex page:
<apex:outputText escape="false" value="{!comment.CommentBody}"/>
b) selectList / selectOptions / selectOption:
If you wish to render non-breakable spaces in options in a select list, the attribute to set is a bit different; either by setting "itemEscaped
" to "false" when using apex:selectOption
, or, if creating SelectOption
objects in the controller, call setEscapeItem(false)
on each SelectOption
that has the values with the
entities.
Source: -https://help.salesforce.com/HTViewSolution?id=000194152&language=en_US
Update
I tried with following code and it is working fine with escape="false"
.
Controller
public String getMyText() {
String myText = 'A B';
return myText;
}
VF Page
Output
A B
Best Answer
I would try several possible solutions:
Just divide output field into the label/value:
Or use outputText:
Or