function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BenBurbridge(JP)BenBurbridge(JP) 

CSS Styles not Rendering in Visualforce PDF attachment

I have a tmeplate which until I refined the styles worked perfectly, below is the code for the attachment portion of the template.
 
<messaging:attachment renderAs="pdf" filename="Patient Treatment Request">

<style type="text/css">

caption {
    border-width: 1px;
    padding: 1px;
    border-style: solid;
    border-color: black;
        text-align: center;
        font-family: Arial;
        background: #940000;
        font-weight: bold;
        font-size: 13px;
        color: #FFFFFF
}

Table {
    border-width: thin;
    border-spacing: 1px;
    border-style: solid;
    border-color: gray;
    background-color: white;
}

Table td:first-child {
        font-weight: bold;
        font-size: 10px;
        text-align: right;
        padding:2px;
}

Table th {
    border-width: 0px;
    padding: 1px;
    border-style: solid;
    border-color: black;
    background-color: #BFBFBF;
    text-align: left;
        font-size:12px;
        font-family: Arial;
        text-align: center;
        font-weight: bold;

}

Table td {
    border-width: 1px;
    padding: 1px;
    border-style: solid;
    border-color: black;
    background-color: white;
    text-align: left;
        font-size:10px;
        font-family: Arial;
        font-weight: normal;
}

.space {
       border-width: 0px;
       }

</style>
<html>
<body>

<div class="Table">
     <table width="100%">
       <caption>Patient Treatment Request Information. Patient:{!relatedTo.Patient_First_Name__c},&nbsp;{!relatedTo.Patient_Last_Name__c}. Coverage Used:{!relatedTo.Division__c}</caption>
                        <tr>
                            <th colspan="2">Patient Demographics</th>
                        </tr>
                        <tr><td height="2px" colspan="2" class="space"></td></tr>
                        <tr>
                            <td width="30%">Patient Name:</td>
                            <td width="70%">{!relatedTo.Patient_First_Name__c},&nbsp;{!relatedTo.Patient_Last_Name__c}</td>
                        </tr>
                        <tr>
                            <td>Date of Birth:</td>
                            <td><apex:outputText value="{0,date,dd-MMMM-yyyy}"><apex:param value="{!relatedTo.Date_of_Birth__c}" /></apex:outputText></td>
                        </tr>
                        <tr>
                            <td>Date of Injury:</td>
                            <td ><apex:outputText value="{0,date,dd-MMMM-yyyy}"><apex:param value="{!relatedTo.Date_of_Accident__c}" /></apex:outputText></td>
                        </tr>
                        <tr>
                            <td>Address:</td>
                            <td>{!relatedTo.Patient_Address_Line_1__c}</td>
                        </tr>
                        <tr>
                            <td>City:</td>
                            <td>{!relatedTo.Patient_City__c}</td>
                        </tr>
                        <tr>
                            <td>Province:</td>
                            <td>{!relatedTo.Patient_Province_State__c}</td>
                        </tr>
                        <tr>
                            <td>Postal Code:</td>
                            <td>{!relatedTo.Patient_Postal_ZIP_Code__c}</td>
                        </tr>
                        <tr>
                            <td>Email Address:</td>
                            <td>{!relatedTo.Patient_Email__c}</td>
                        </tr>
                        <tr>
                            <td>Patient Telephone Numbers:</td>
                            <td>{!relatedTo.Patient_Contact_Details__c}</td>
                        </tr>
                        <tr><td height="5px" colspan="2" class="space"></td></tr>

                        <tr>
                            <th colspan="2">Patient Alternative Contact Details / Emergency Contact</th>
                        </tr>
                        <tr><td height="2px" colspan="2" class="space"></td></tr>
                        <tr>
                            <td style="font-weight: bold">Patient Alternative Contact Details / Emergency Contact Details</td>
                            <td colspan="2"><apex:outputText value="{!relatedTo.Emergency_Contact_Information__c}" escape="false"/></td>
                        </tr>
                        <tr><td height="5px" colspan="2" class="space"></td></tr>

                        <tr>
                            <th colspan="2">Patient Insurance Details</th>
                        </tr>
                        <tr><td height="2px" colspan="2" class="space"></td></tr>
                        <tr>
                            <td style="font-weight: bold">Patient Insurance Details</td>
                            <td colspan="2"><apex:outputText value="{!relatedTo.Patient_Insurance_Information__c}" escape="false"/></td>
                        </tr>
                        <tr><td height="5px" colspan="2" class="space"></td></tr>

                        <tr>
                            <th colspan="2">Patient Employment Details (If Available)</th>
                        </tr>
                        <tr><td height="2px" colspan="2" class="space"></td></tr>
                        <tr>
                            <td style="font-weight: bold">Patient Employment Details (If available)</td>
                            <td colspan="2"><apex:outputText value="{!relatedTo.Patient_Employment_Details__c}" escape="false"/></td>
                        </tr>
                        <tr><td height="5px" colspan="2" class="space"></td></tr>

                        <tr>
                            <th colspan="2">Patient Injury Related Information</th>
                        </tr>
                        <tr><td height="2px" colspan="2" class="space"></td></tr>
                        <tr>
                            <td width="15%">Area of Main Injury:</td>
                            <td width="45%">{!relatedTo.Area_Of_Pain_Area_1__c}</td>
                        </tr>
                        <tr>
                            <td>Current NPRS:</td>
                            <td>{!relatedTo.NPRS_Current_Area_1__c}</td>
                        </tr>
                        <tr>
                            <td>Chief Concern:</td>
                            <td>{!relatedTo.Chief_Concern__c}</td>
                        </tr>
                        <tr><td height="5px" colspan="2" class="space"></td></tr>
                        <tr>
                            <td>Undertaken Diagnostics:</td>
                            <td>{!relatedTo.Diagnostics__c}</td>
                        </tr>
                        <tr>
                            <td>Other Diagnostics Description:</td>
                            <td>{!relatedTo.Diagnostic_Other__c}</td>
                        </tr>
                        <tr>
                            <td>Any Allergies:</td>
                            <td>{!relatedTo.Listed_Allergies__c}</td>
                        </tr>
                        <tr>
                            <td>Current Medications:</td>
                            <td>{!relatedTo.Medications__c}</td>
                        </tr>
                        <tr>
                            <td>Any Pertinent Medical Conditions:</td>
                            <td>{!relatedTo.Medical_Questionnaire__c}</td>
                        </tr>
                        <tr><td height="5px" colspan="2" class="space"></td></tr>

                        <tr>
                            <td colspan="2" style="font-size:6pt;text-align:center;">CONFIDENTIALITY NOTE:  This communication (and any information or material transmitted with this communication) is confidential, may be privileged and is intended only for the use of the intended recipient.  If you are not the intended recipient, any review, retransmission, conversion to hard copy, copying, circulation, publication, dissemination, distribution, reproduction or other use of this communication, information or material is strictly prohibited and may be illegal.  If you received this communication in error, please notify the sender immediately by return mail and delete this communication, information and material from any computer, disk drive, diskette or other storage device or media.  Thank you.</td>
                        </tr>
                        <tr>
                            <td colspan="2" style="font-size:6pt;text-align:center;">AVIS DE CONFIDENTIALITE-: Ce courrier électronique (ainsi que toute information ou matériel transmis par cette communication) est confidentielle, peut être privilégiée, et est destinée que pour l’usage du destinataire adressé. Si vous n’êtes pas le destinataire adressé, toute lecture, retransmission, conversion, copie, circulation, publication, diffusion, distribution, reproduction, ou autre usage de cette communication, information ou matériel est strictement interdit, voire même illégal. Si vous avez reçu cette communication en erreur, s’il-vous-plaît immédiatement avertir l’expéditeur et supprimer cette communication, information et materiel de tout ordinateur, disque dur, disquette ou autre périphérique.  Merci de votre coopération.</td>
                        </tr>
     </table>
</div>
</body>
</html>
</messaging:attachment>
</messaging:emailTemplate>

The font formatting etc works but the borders are not rendering at all?

Help required .. thanks
Best Answer chosen by BenBurbridge(JP)
bob_buzzardbob_buzzard
In my experience, the Visualforce PDF rendering engine is quite picky about where it gets its styles from, especially around tables.  I've always ended up using inline styles rather than CSS I'm afraid.

All Answers

bob_buzzardbob_buzzard
In my experience, the Visualforce PDF rendering engine is quite picky about where it gets its styles from, especially around tables.  I've always ended up using inline styles rather than CSS I'm afraid.
This was selected as the best answer
BenBurbridge(JP)BenBurbridge(JP)
Yes, thanks Bob.

I did end up using a mix of inline and styles but got there in the end.