1

A string containing greater than or less than sign in the Apex class is rendered in vf pdf page without the > or < than operators example: String in controller = '≤a' vf pdf page it is displayed as 'a'.

How to display the string as with the sign on vf pdf page.

1
  • I can't reproduce this myself. Copy/pasting ≤ into visualforce directly, using the HTML entity &le;, and copy/pasting it into a String in a controller and using {!myString} syntax all work for me. Are you sure that you've used UTF-8 encoding when developing your page/controller? If not, that could be your problem.
    – Derek F
    Apr 25, 2017 at 16:25

1 Answer 1

5

Update and complete solution for pdf rendering with Special characters

If the PDF file fails to display all the page’s text, particularly multibyte characters such as Japanese or accented international characters, adjust your CSS to use a font that supports them.

Here escape attribute doesn't matter. only following style for font matters where that particular character code supports.

<style>
    body { font-family: 'Arial Unicode MS'; }
</style> 

Visualforce

<apex:page standardController="Opportunity" renderAs="pdf"   applybodyTag="false" 
showHeader="false">
<head>
<style>
    body { font-family: 'Arial Unicode MS'; }
</style> 
<div>
    {!myvalue}
</div>
<apex:outputText value="{!myvalue}" escape="false" />
</apex:page>

Results:

pdf render

Refer Visualforce PDF Rendering Considerations and Limitations

6
  • Sorry the sign I need to display is '≤'. If the string contains '≤abc' only abc is displayed on vfpage
    – V C
    Apr 25, 2017 at 16:09
  • ≤ is not a sensitive HTML character (it is quite different from &lt; which is an HTML character), so I'd expect that escape="false" would do nothing.
    – Derek F
    Apr 25, 2017 at 16:14
  • I have checked that "≤Test" is perfectly displaying for me using that escape="false" Apr 25, 2017 at 16:20
  • I don't know why it's not working with you or what is missed in the question,I have tried same and that worked fine for me My Controller public class TestOnly{ public String myvalue {get; set;} public TestOnly(){ myvalue = '≤abc'; } } My VF <apex:page controller="TestOnly" sidebar="false"> <apex:form > {!myvalue}<br/> <apex:outputText value="{!myvalue}" escape="false"/><br/> <apex:outputText value="{!myvalue}"/><br/> </apex:form> </apex:page> Output is ≤abc ≤abc ≤abc Apr 25, 2017 at 16:20
  • It works for me even when explicitly setting <apex:outputText value="{!myvalue}" escape="true"/>. This is not the solution to the problem.
    – Derek F
    Apr 25, 2017 at 16:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .