Multi-Currency on Visualforce pages

Currency formatting is very common task when you need to bring financial data to the UI. Salesforce has Currency data type and it’s a best choice to store financial data. But when you need to display it on UI it might be tricky. So, my initial setup for this post as follow: I have a quote with quote line items related to it and I need to generate PDF with all that data formatted.

Basically you can use the following code

<apex:outputText value="{0, number, Currency}">
    <apex:param value="{!qli.TotalPrice}" />
</apex:outputText>

This code will be working just fine until you need to display currency which differs from your organization default currency. For my case it was EURO. When I used above code PDF looks like that

hmmm, where’s my euros?

The next thing you can try is to set display format explicitly

<apex:outputText value="{!'{0, number, ‘###,###,###.00′}’}">
    <apex:param value="{!qli.TotalPrice}">
</apex:outputText>

It will print currency in correct format but without currency symbol. Finally in order to have correct format you have to add currency symbol to your formatting expression. You could do it in this way

<apex:outputText value="{!'{0, number,’ + quote.CurrencySymbol + ‘###,###,##0.00}’}">
    <apex:param value="{!qli.TotalPrice}" />
</apex:outputText>

Or like that

<apex:outputText value="{!quote.CurrencySymbol + ‘{0,number, ###,###,###.00}’}">
    <apex:param value="{!qli.TotalPrice}" />
</apex:outputText>

and result will be following with correct currency symbol which you have to define via apex controller

[salesforce][visualforce]