1

I am not sure why Khmer fonts are not supported in Visualforce page. The below are the fonts that are supported by VF page.

Font Type Fonts
Arial Unicode MS Arial Unicode MS
Helvetica sans-serif, SansSerif, Dialog
Times serif, Times
Courier monospace, courier, monospaced, dialoginput
  • It seems like of all the fonts mentioned below, only Arial Unicode font supports Visualforce PDF rendering as per the article: https://help.salesforce.com/articleView?id=000321277&type=1&mode=1
  • I tried to test it myself with a sample code and it worked when you don’t render it as pdf and just render it in a page. When I add renderAs = pdf, it doesn’t display the Khmer characters. I tried Thai characters with font-family as Arial Unicode MS and it works in both in a page and in pdf.
  • Also, web fonts are not supported when you render it as pdf.

In a Web Page - Khmer fonts are displayed

In a Web page

In PDF - Khmer fonts are not displayed

enter image description here

Here is my code for you to try it out:

<apex:page showHeader="false" applyBodyTag="false" renderAs="pdf">
    <head>
        <link rel="preconnect" href="https://fonts.gstatic.com"/>
        <link href="https://fonts.googleapis.com/css2?family=Khmer&display=swap" rel="stylesheet"/>
        <style>
            body {
            font-family: 'Khmer ';
            }
        </style>
    </head>
    <body>
        
        ឲ្យខ្លាច <br/>
        This is a sample page: API version 28.0
        
    </body>
</apex:page>

Please let me know if there are any alternatives to solve the problem.

2 Answers 2

1

You are only specifically allowed to use the named fonts in the list (that's just four fonts). You can't use any other font, even if they may happen to be a "serif" font. You are not allowed to use custom web fonts, either. I do find it interesting that it doesn't render at all, but this isn't exactly surprising. Use only the allowed fonts to avoid rendering problems.

If you want to share code, you should be able to specify a fallback font:

    <style>
        body {
        font-family: 'Khmer','sans-serif';
        }
    </style>
1

The documentation from which the above font table derive explicitly states

Web fonts aren’t supported when the page is rendered as a PDF file. You can use web fonts in your Visualforce pages when they’re rendered normally.

The PDF engine used to render Visualforce pages does not support a wide variety of modern Web technologies. If you need sophisticated PDF rendering that goes above and beyond those capabilities, consider another solution:

  • Building an off-platform application on Heroku or another solution, where you can make use of PDF generation libraries in your language of choice. ([Safe harbor]: Salesforce Functions, formerly Evergreen, may be a strong candidate for this use case when it is GA).
  • Generating the PDF file on the front end using a JavaScript PDF library.
  • Purchasing an AppExchange document generation solution that offers broader font support.

You must log in to answer this question.

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