1

We have a visualforce page rendered as PDF that uses some tables and css for simple styling, the problem is that in the production org it's not displaying any of the css (we are even using some old html/css techniques and inline css) like border, padding, position, tables width attribute, tag, etc.

Code:

<apex:page standardController="Namespace__Custom__c" extensions="Ext" action="{!init}" showHeader="false" renderAs="PDF" docType="html-5.0" applyBodyTag="false">
    <head>
        <style type="text/css">
        @page 
        {
            margin-left: {!documentBuilder.Namespace__Document_left_margin__c}cm;
            margin-right: {!documentBuilder.Namespace__Document_right_margin__c}cm;            
            margin-top: {!documentBuilder.Namespace__Document_top_margin__c}cm;
            margin-bot: {!documentBuilder.Namespace__Document_bot_margin__c}cm;
            @bottom-center 
            {
                content: element(footer);
            }
        }
        div.footer
        {               
            padding: 10px;       
            position: running(footer);           
        }   
        body
        {
            font-family: {!documentBuilder.Font__c};
        }
        </style>
    </head>
    <body>
        <table width="100%">
            <div class="footer" style="text-align:center; font-size: 10pt; color:#777777">
                <div>
                    <apex:outputText value="{!footer}" style="text-align:center;left:50%;position:relative;display:block;"/>
                </div>
            </div>
            <tr>
                <td width="50%"><apex:outputText value="{!p1}"/><br/><br/></td>
            </tr>
            <tr>
                 <td width="50%">
                     <table width="50%">
                         <tr>
                             <td width="60%"><apex:outputLabel value="{!$ObjectType.Namespace__Custom__c.fields.Field1__c.label}:" style="color:#888888;line-height:45px;"/><br/>
                             <apex:outputLabel value="{!$ObjectType.Namespace__Custom__c.fields.Field2__c.label}:" style="color:#888888;"/><br/><br/></td>
                             <td><apex:outputText value=" {!factureNumber}" style="border:1px solid #888888;padding:1px 8px 1px 0;position:relative;top:0;"/><br/>
                             <apex:outputText value=" {!date1}" style="border:1px solid #888888;padding:1px 5px 1px 0;position:relative;top:13px;"/><br/><br/></td>
                         </tr>
                     </table>


                    </td>
                </tr>
                <tr><td width="100%" style="background-color:#000;"></td></tr>
                <tr>
                    <td width="100%">
                        <table width="100%">
                            <tr>
                                <td width="67%"></td>
                                <td><br/>
                                    <b><apex:outputText value="{!account1}"/></b><br/>
                                    <apex:outputText value="{!clientAccountAddress}"/><br/><br/>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td width="100%">
                        <table width="100%"><tr>
                            <td width="10%" style="vertical-align:top;padding:5px 0;"><apex:outputLabel style="color:#888888;" value="{!$ObjectType.Namespace__Custom__c.fields.Field3__c.label}:"/></td>
                            <td style="height:200px;vertical-align:top;border:1px solid #cecece;padding:5px;"><apex:outputText value="{!content}"/></td>
                        </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td width="100%">
                        <table width="100%">
                            <tr>
                                <td width="45%"></td>
                                <td>
                                    <table>
                                        <tr>
                                            <td><apex:outputLabel value="{!$ObjectType.Namespace__Custom__c.fields.Field4__c.label}:" style="padding:0;color:#888888;line-height:25px;"/><br/>
                                            <apex:outputLabel value="{!$ObjectType.Namespace__Custom.fields.Field5__c.label}:" style="color:#888888;line-height:25px;"/><br/>
                                            <apex:outputLabel value="{!$ObjectType.Namespace__Custom__c.fields.Namespace__Field6.label}:" style="color:#888888;line-height:35px;"/><br/>
                                            </td>
                                            <td><apex:outputText value="{!taxes}%" style="position:relative;top:-6px;"/></td>
                                            <td><apex:outputText value=" {!amount}" style="float:right;border:1px solid #56728a;background-color:#b5d5ff;padding:0 0 0 30px;position:relative;margin-top:-8px;"/><br/>
                                            <apex:outputText value="{!tax} {!currencySymbol}" style="float:right;position:relative;top:-4px;"/><br/>
                                            <span style="border-top:1px solid #000;height:0.1px;width:100%;display:block;position:inherit;"></span>
                                            <apex:outputText value="{!total} {!currencySymbol}" style="float:right;position:relative;margin-top:11px;"/><br/>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td width="50%">
                        <apex:outputText value="{!p2}" style="font-weight:bold;text-transform:uppercase;"/>
                    </td>
                </tr>
        </table>
   </body>

In the sandbox (and a developer org) it looks just as it should, but in production it doesn't.

Update:

We're getting (only in the one that fails) Failed to load resource: net::ERR_CACHE_MISS error in the browser console when the page loads.

Any ideas why this can be happening? Thanks in advanced!

  • 1
    Are all three orgs on the same SalesForce version? Spring '15 is currently being rolled out so you might have different versions in your orgs. trust.salesforce.com/trust/maintenance – BarCotter Jan 14 '15 at 18:42
  • Hi @BarCotter, they are all in: Salesforce.com Enterprise Web Services API Version 32.0 – Jose Jan 14 '15 at 19:09
1

Turns out it was a CSS error, the line:

body
    {
        font-family: {!documentBuilder.Font__c};
    }

Was getting populated as:

body
    {
        font-family: Arial Unicode MS;
    }

(as recommended here), and that broke all the page css, when we change it to:

body
    {
        font-family: Arial;
    }

it worked just fine.

I'm not sure if this is a bug from last Salesforce update, but for now, for us, the fonts are only working as simple Arial, Dialog, Times and Courier not with the "Style font-family Value to Use (Font Synonyms)" salesforce recommends.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.