Search code examples
htmlcsssalesforcevisualforce

Visualforce Style issues when rendering as pdf


I need to display a legal document. Most of the text inside a p tag is normal; but the first word on every paragraph must be bold. Font size, font family and text align work fine; it's just the strong tag that is not working:

    <apex:page renderAs="pdf" controller="FiniquitosController" showHeader="false" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false">
      <head>
    <style>
        strong {
            font-weight: bold;
        }
    </style>
    </head>

    <p style="text-align: justify; line-height: normal; font: 10pt Arial Unicode MS;">
    <strong>PRIMERO.</strong> Rest of the text     
    </p>
    </apex:page>

Solution

  • "Arial Unicode MS", is the only font with full unicode support in Visual force pdf engine, great for Arabic, Chinese/Japanese/Korean etc. BUT it doesn't have bold variant so all your <b>, <th>, strong etc will print with normal font weight.

    If you need a different font / want to experiment - use this as base: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_output_pdf_supported_fonts.htm

    Check out my full answer, maybe the jspdf trick will be an option for you. https://stackoverflow.com/a/60402680/313628