You need to sign in to do that
Don't have an account?
Arnaud Crucifix
Fonts rendering Visualforce PDF
Hello,
Initialy I was looking for implementing custom font in my PDF render, but according to this page: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_output_pdf_supported_fonts.htm this is not possible, and I can only use 4 predefined font (Arial, Helvetica, Times, Courier). Ok I will try with them.
I would like to use Helvetica, based on the documentation I have to use the font-family: sans-serif, SansSerif, Dialog.
Here is my page code example:
But after the render of the page, the font outputed is not Helvetica but Arial. I've made a small screen comparaison to show what I mean (the small pink circle is here to show, small difference)
Any idea why ?
Thanks,
Initialy I was looking for implementing custom font in my PDF render, but according to this page: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_output_pdf_supported_fonts.htm this is not possible, and I can only use 4 predefined font (Arial, Helvetica, Times, Courier). Ok I will try with them.
I would like to use Helvetica, based on the documentation I have to use the font-family: sans-serif, SansSerif, Dialog.
Here is my page code example:
<apex:page docType="html-5.0" showHeader="false" sidebar="false" standardStylesheets="true" applyBodyTag="false" applyHtmlTag="false" renderAs="PDF"> <html> <head> </head> <body> <ul> <li><span style="font-family: sans-serif; font-size: 14pt;">sans-serif</span></li> <li><span style="font-family: SansSerif; font-size: 14pt;">SansSerif</span></li> <li><span style="font-family: Dialog; font-size: 14pt;">Dialog</span></li> </ul> </body> </html> </apex:page>
But after the render of the page, the font outputed is not Helvetica but Arial. I've made a small screen comparaison to show what I mean (the small pink circle is here to show, small difference)
Any idea why ?
Thanks,
Fonts Available When Using Visualforce PDF Rendering
Visualforce PDF rendering supports a limited set of fonts. Use the following font names to ensure that PDF output renders as you expect.
The fonts available when you’re rendering a page as a PDF are as follows. The first listed font-family value for each typeface is the recommended choice.
Typeface
Style font-family Value to Use (Font Synonyms)
- Arial Unicode MS
- Arial Unicode MS
- Helvetica
- sans-serif
- SansSerif
- Dialog
- Times
- serif
- Times
- Courier
- monospace
- Courier
- Monospaced
- DialogInput
NoteThese rules apply to server-side PDF rendering. You might see different results when viewing pages in a web browser.
Text styled with any value besides those listed above receives the default font style, Times. This means that, ironically, while Helvetica’s synonyms render as Helvetica, using “Helvetica” for the font-family style renders as Times. We recommend using “sans-serif”.
Arial Unicode MS is the only multi-byte font available, providing support for the extended character sets of languages that don’t use the Latin character set.
- https://developer.salesforce.com/forums/?id=906F000000094VnIAI
- https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_output_pdf_supported_fonts.htm (https://developer.salesforce.com/forums/?id=906F000000094VnIAI)
- https://salesforce.stackexchange.com/questions/53774/custom-fonts-in-visualforce-page-renderas-pdf
Hope it helpsPlease mark it the best answer so that they removed from a unanswer question and more app as a proper solution.
Thanks
Rahul Kumar
I tottaly understand the point about limited supported font.
But I still have an issue here, even if I declare font using these 3 (sans-serif, SansSerif, Dialog) where I'm expecting Helvetica output, the font rendered is in fact Arial. (Cfr my screenshot with the comparaison).
Do you have any idea why ? At least if Helvetica is in fact not supported, the doc need to be updated.
Thanks