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
pj6284pj6284 

Render-as PDF: Where'd the colors go?

Using the page attribute render-as="pdf" is giving me a monochrome PDF despite the use of CSS on the page to set the background-color in some table cells. The background colors render fine in HTML but are absent in PDF. Is it possible to get color in the PDF (color fidelity not an issue)?
VisualForceVisualForce

Hi..

Its work for me... Can u post ur code  

   Use inline style or styleclass .. The following code perfectly work for me..

VF code:

     <table width="100%">
       <tr>
             <td> Test</td><td style="color:green">Green</td>
       </tr>
     </table>

css file :

td {
background-color: #add3c8;
text-align:center;
border: none;
}
pj6284pj6284
Thanks for responding. Here's a snippet of code:


<br>TH {<br> background-color: #99CCFF;<br> align: center;<br>}<br>.criteria {<br> background-color: #FFFF92;<br> font-weight: bold;<br>}<br>



Criteria


...
...



WITHOUT the page attribute 'render-as="pdf",' the colors render as I'd expect: the first row, which I've given the "header" facet, renders with the TH style, and the subsequent rows, which I've put in the "criteria" style class, render with the .criteria style.

If I add the render-as attribute, however, the page renders monochrome.

Thanks.
pj6284pj6284
Whoops -- sample code didn't render. Here's another attempt with the angle brackets replaced:

[apex:page controller="Controller" showHeader="false" standardStyleSheets="true" sidebar="false"]
[style]
TH {
background-color: #99CCFF;
align: center;
}
.criteria {
background-color: #FFFF92;
font-weight: bold;
}
[/style]

[apex:dataTable value="{!query}" var="var" border="1"]
[apex:column styleClass="criteria"]
[apex:facet name="header"]Criteria[/apex:facet]
[apex:outputText value="{!var.Name}"/]
[/apex:column]

...
...
[/apex:dataTable]

WITHOUT the page attribute 'render-as="pdf",' the colors render as I'd expect: the first row, which I've given the "header" facet, renders with the TH style, and the subsequent rows, which I've put in the "criteria" style class, render with the .criteria style. If I add the render-as attribute, however, the page renders monochrome. Thanks.
MohanaGopalMohanaGopal
Code:
<apex:page standardcontroller="Account" renderas="pdf">

<apex:dataTable value="{!Account.Contacts}" var="con" width="100%" >
<apex:column>
<apex:facet name="header">Account</apex:facet>
<apex:outputtext value="{!con.Account.Name}" style="background-color: #99CCFF;align: center;"/>
</apex:column>

<apex:column headervalue="Contact Name" value="{!con.Name}"/>
</apex:dataTable>
</apex:page>

 
Hi..
 
    Can u try inline style class... Instead of styleclass..Its work..
 
 
 
 
 
mpoiriermpoirier

Hello,

 

I have the same problem using style sheets.

 

Will there be a fix for this soon ?

 

Thanks,

 

Michel